From 647fa83e3219b023283448e7fca9454b64188b69 Mon Sep 17 00:00:00 2001 From: Husain Baghwala Date: Mon, 15 Dec 2025 10:48:42 +0530 Subject: [PATCH 1/2] feat: add support for OPENAI_API_KEY_GPT_5_NANO in configuration and enhance API key validation logic --- config.py | 3 ++- src/services/utils/getConfiguration_utils.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/config.py b/config.py index 2c13e335..f70f058c 100644 --- a/config.py +++ b/config.py @@ -58,4 +58,5 @@ class Config: DOCSTAR_ORG_ID = os.getenv('DOCSTAR_ORG_ID') DOCSTAR_COLLECTION_ID = os.getenv('DOCSTAR_COLLECTION_ID') AI_ML_APIKEY = os.getenv('AI_ML_APIKEY') - AI_MIDDLEWARE_PAUTH_KEY = os.getenv('AI_MIDDLEWARE_PAUTH_KEY') \ No newline at end of file + AI_MIDDLEWARE_PAUTH_KEY = os.getenv('AI_MIDDLEWARE_PAUTH_KEY') + OPENAI_API_KEY_GPT_5_NANO = os.getenv('OPENAI_API_KEY_GPT_5_NANO') \ No newline at end of file diff --git a/src/services/utils/getConfiguration_utils.py b/src/services/utils/getConfiguration_utils.py index ba98ce75..40fbebd9 100644 --- a/src/services/utils/getConfiguration_utils.py +++ b/src/services/utils/getConfiguration_utils.py @@ -210,11 +210,17 @@ def setup_api_key(service, result, apikey, chatbot): if folder_api_key: db_api_key = folder_api_key + # Validate API key existence if chatbot and (service == 'openai'): - if not apikey and result.get('bridges', {}).get('configuration', {}).get('model') == 'gpt-5-nano': - apikey = Config.OPENAI_API_KEY + model = result.get('bridges', {}).get('configuration', {}).get('model') + # If both keys are not present + if not (apikey or db_api_key): + # Use Config.OPENAI_API_KEY only if model is gpt-5-nano + if model == 'gpt-5-nano': + apikey = Config.OPENAI_API_KEY_GPT_5_NANO + else: + raise Exception('Could not find api key or Agent is not Published') - # Validate API key existence if not (apikey or db_api_key): raise Exception('Could not find api key or Agent is not Published') From 689657ce376c4e3bd551b8195b41fd9f85558c0e Mon Sep 17 00:00:00 2001 From: Husain Baghwala Date: Mon, 15 Dec 2025 10:50:22 +0530 Subject: [PATCH 2/2] chore: update OpenAI service version to gpt-5-nano in configuration --- src/configs/constant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/configs/constant.py b/src/configs/constant.py index b0e750ee..a0ffdd8b 100644 --- a/src/configs/constant.py +++ b/src/configs/constant.py @@ -60,7 +60,7 @@ } new_agent_service = { - "openai": "gpt-4o", + "openai": "gpt-5-nano", "anthropic": "claude-3-7-sonnet-latest", "groq": "llama-3.3-70b-versatile", "open_router": "deepseek/deepseek-chat-v3-0324:free",