From e20c254636a4ab52ca1003e4fae1848cc0e91737 Mon Sep 17 00:00:00 2001 From: Robert Scholes Lyck Date: Tue, 27 Feb 2024 09:34:01 +0100 Subject: [PATCH] Move api_key from additional kwargs to openai instantiation The openai api config key is caused issue for azure openai, when passed in additional kwargs to litellm completion. Instead it is passed as arg to OpenAI instantiation. --- sgpt/handlers/handler.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sgpt/handlers/handler.py b/sgpt/handlers/handler.py index 130941ee..17de257b 100644 --- a/sgpt/handlers/handler.py +++ b/sgpt/handlers/handler.py @@ -13,7 +13,6 @@ use_litellm = cfg.get("USE_LITELLM") == "true" additional_kwargs = { "timeout": int(cfg.get("REQUEST_TIMEOUT")), - "api_key": cfg.get("OPENAI_API_KEY"), "base_url": None if base_url == "default" else base_url, } @@ -25,7 +24,7 @@ else: from openai import OpenAI - client = OpenAI(**additional_kwargs) # type: ignore + client = OpenAI(api_key=cfg.get("OPENAI_API_KEY"), **additional_kwargs) # type: ignore completion = client.chat.completions.create additional_kwargs = {}