From 8a242103fcc95412c514086e22ba14c13be159a1 Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Wed, 29 Nov 2023 11:38:53 -0500 Subject: [PATCH] use platform api key if the access code is correct --- backend/main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/main.py b/backend/main.py index eb1b0f9..117c58c 100644 --- a/backend/main.py +++ b/backend/main.py @@ -81,7 +81,17 @@ async def stream_code(websocket: WebSocket): # If neither is provided, we throw an error. openai_api_key = None if "accessCode" in params and params["accessCode"]: - print("Using access code") + print("Access code - using platform API key") + if params["accessCode"] == "hi": + openai_api_key = os.environ.get("PLATFORM_OPENAI_API_KEY") + else: + await websocket.send_json( + { + "type": "error", + "value": "Invalid access code. Please try again.", + } + ) + return else: if params["openAiApiKey"]: openai_api_key = params["openAiApiKey"]