From 9fa1cf3edf9ce455fb3b3d7279809c40aa9be627 Mon Sep 17 00:00:00 2001 From: Sergio Prada Date: Mon, 18 Dec 2023 22:03:37 -0500 Subject: [PATCH 1/2] accept base api base for openai --- src/models.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/models.rs b/src/models.rs index 130276d..38502b5 100644 --- a/src/models.rs +++ b/src/models.rs @@ -55,10 +55,24 @@ impl Manager for OpenAIClientManager { completion_client: Client::with_config(config), } } - _ => AnyOpenAIClient::OpenAI { - embedding_client: Client::new(), - completion_client: Client::new(), - }, + _ => { + let openai_api_base = env::var("OPENAI_API_BASE"); + + if let Ok(openai_api_base) = openai_api_base { + let embedding_config = OpenAIConfig::default().with_api_base(&openai_api_base); + let completion_config = OpenAIConfig::default().with_api_base(&openai_api_base); + + AnyOpenAIClient::OpenAI { + embedding_client: Client::with_config(embedding_config), + completion_client: Client::with_config(completion_config), + } + } else { + AnyOpenAIClient::OpenAI { + embedding_client: Client::new(), + completion_client: Client::new(), + } + } + } }; Ok(openai_client) } From 4e52a0167077f4f264bb7bcbf177fa5d03a173f9 Mon Sep 17 00:00:00 2001 From: Sergio Prada Date: Mon, 18 Dec 2023 22:04:24 -0500 Subject: [PATCH 2/2] readme update --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9d6d5b7..e0ea18f 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ Searches are segmented (filtered) by the session id provided automatically. - `PORT` (default:8000) - Motorhead Server Port - `OPENAI_API_KEY`- [Your api key](https://platform.openai.com/account/api-keys) to connect to OpenAI. - `REDIS_URL` (required)- URL used to connect to `redis`. +- `OPENAI_API_BASE` (default:https://api.openai.com/v1) - OpenAI API Base URL ### Azure deployment