From b46d08b41650844d9733e81f2a363fd25d0eb645 Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Wed, 29 Nov 2023 11:35:04 -0500 Subject: [PATCH] read access code from params --- backend/main.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/main.py b/backend/main.py index 4b75f71..eb1b0f9 100644 --- a/backend/main.py +++ b/backend/main.py @@ -79,13 +79,17 @@ async def stream_code(websocket: WebSocket): # Get the OpenAI API key from the request. Fall back to environment variable if not provided. # If neither is provided, we throw an error. - if params["openAiApiKey"]: - openai_api_key = params["openAiApiKey"] - print("Using OpenAI API key from client-side settings dialog") + openai_api_key = None + if "accessCode" in params and params["accessCode"]: + print("Using access code") else: - openai_api_key = os.environ.get("OPENAI_API_KEY") - if openai_api_key: - print("Using OpenAI API key from environment variable") + if params["openAiApiKey"]: + openai_api_key = params["openAiApiKey"] + print("Using OpenAI API key from client-side settings dialog") + else: + openai_api_key = os.environ.get("OPENAI_API_KEY") + if openai_api_key: + print("Using OpenAI API key from environment variable") if not openai_api_key: print("OpenAI API key not found")