From db9f8a2749e5f44585b2ad7514f346e7a5a9a26b Mon Sep 17 00:00:00 2001 From: Kory Becker Date: Wed, 12 Apr 2023 22:14:51 -0400 Subject: [PATCH 1/2] Added config option for OPENAI_API_TYPE=azure_ad --- scripts/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/config.py b/scripts/config.py index 255587d76..4f8961264 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -51,7 +51,8 @@ class Config(metaclass=Singleton): self.openai_deployment_id = os.getenv("OPENAI_AZURE_DEPLOYMENT_ID") self.azure_chat_deployment_id = os.getenv("OPENAI_AZURE_CHAT_DEPLOYMENT_ID") self.azure_embeddigs_deployment_id = os.getenv("OPENAI_AZURE_EMBEDDINGS_DEPLOYMENT_ID") - openai.api_type = "azure" + openai.api_type = os.getenv("OPENAI_API_TYPE", "azure") + openai.api_base = self.openai_api_base openai.api_version = self.openai_api_version From da247ca600dd0961d2ba8d3ea69819121f589468 Mon Sep 17 00:00:00 2001 From: Kory Becker Date: Thu, 13 Apr 2023 12:47:16 -0400 Subject: [PATCH 2/2] merge fix --- azure.yaml.template | 1 + scripts/config.py | 13 ++++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/azure.yaml.template b/azure.yaml.template index 852645ca0..74ca797b2 100644 --- a/azure.yaml.template +++ b/azure.yaml.template @@ -1,3 +1,4 @@ +azure_api_type: azure_ad azure_api_base: your-base-url-for-azure azure_api_version: api-version-for-azure azure_model_map: diff --git a/scripts/config.py b/scripts/config.py index 0270dbec0..03d48dd43 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -45,18 +45,12 @@ class Config(metaclass=Singleton): self.openai_api_key = os.getenv("OPENAI_API_KEY") self.temperature = int(os.getenv("TEMPERATURE", "1")) - self.use_azure = False self.use_azure = os.getenv("USE_AZURE") == 'True' self.execute_local_commands = os.getenv('EXECUTE_LOCAL_COMMANDS', 'False') == 'True' if self.use_azure: - self.openai_api_base = os.getenv("OPENAI_AZURE_API_BASE") - self.openai_api_version = os.getenv("OPENAI_AZURE_API_VERSION") - self.openai_deployment_id = os.getenv("OPENAI_AZURE_DEPLOYMENT_ID") - self.azure_chat_deployment_id = os.getenv("OPENAI_AZURE_CHAT_DEPLOYMENT_ID") - self.azure_embeddigs_deployment_id = os.getenv("OPENAI_AZURE_EMBEDDINGS_DEPLOYMENT_ID") self.load_azure_config() - openai.api_type = os.getenv("OPENAI_API_TYPE", "azure") + openai.api_type = self.openai_api_type openai.api_base = self.openai_api_base openai.api_version = self.openai_api_version @@ -126,8 +120,9 @@ class Config(metaclass=Singleton): config_params = yaml.load(file, Loader=yaml.FullLoader) except FileNotFoundError: config_params = {} - self.openai_api_base = config_params.get("azure_api_base", "") - self.openai_api_version = config_params.get("azure_api_version", "") + self.openai_api_type = os.getenv("OPENAI_API_TYPE", config_params.get("azure_api_type", "azure")) + self.openai_api_base = os.getenv("OPENAI_AZURE_API_BASE", config_params.get("azure_api_base", "")) + self.openai_api_version = os.getenv("OPENAI_AZURE_API_VERSION", config_params.get("azure_api_version", "")) self.azure_model_to_deployment_id_map = config_params.get("azure_model_map", []) def set_continuous_mode(self, value: bool):