mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Use api_key keyword argument to set the openai_api_key parameter for GPT
This commit is contained in:
parent
7af8a56434
commit
6508379d7b
1 changed files with 3 additions and 1 deletions
|
@ -41,7 +41,9 @@ max_prompt_size = {"gpt-3.5-turbo": 4096, "gpt-4": 8192}
|
||||||
)
|
)
|
||||||
def completion_with_backoff(**kwargs):
|
def completion_with_backoff(**kwargs):
|
||||||
prompt = kwargs.pop("prompt")
|
prompt = kwargs.pop("prompt")
|
||||||
if "openai_api_key" not in kwargs:
|
if "api_key" in kwargs:
|
||||||
|
kwargs["openai_api_key"] = kwargs.get("api_key")
|
||||||
|
elif "openai_api_key" not in kwargs:
|
||||||
kwargs["openai_api_key"] = os.getenv("OPENAI_API_KEY")
|
kwargs["openai_api_key"] = os.getenv("OPENAI_API_KEY")
|
||||||
llm = OpenAI(**kwargs, request_timeout=10, max_retries=1)
|
llm = OpenAI(**kwargs, request_timeout=10, max_retries=1)
|
||||||
return llm(prompt)
|
return llm(prompt)
|
||||||
|
|
Loading…
Reference in a new issue