mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 13:25:11 +00:00
No need to set OpenAI API key from environment variable explicitly
It is unnecessary as the OpenAI client automatically tries to use API key from OPENAI_API_KEY env var when the api_key field is unset
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
@@ -40,7 +39,7 @@ def completion_with_backoff(
|
|||||||
client: openai.OpenAI = openai_clients.get(client_key)
|
client: openai.OpenAI = openai_clients.get(client_key)
|
||||||
if not client:
|
if not client:
|
||||||
client = openai.OpenAI(
|
client = openai.OpenAI(
|
||||||
api_key=openai_api_key or os.getenv("OPENAI_API_KEY"),
|
api_key=openai_api_key,
|
||||||
base_url=api_base_url,
|
base_url=api_base_url,
|
||||||
)
|
)
|
||||||
openai_clients[client_key] = client
|
openai_clients[client_key] = client
|
||||||
@@ -102,7 +101,7 @@ def llm_thread(g, messages, model_name, temperature, openai_api_key=None, api_ba
|
|||||||
client_key = f"{openai_api_key}--{api_base_url}"
|
client_key = f"{openai_api_key}--{api_base_url}"
|
||||||
if client_key not in openai_clients:
|
if client_key not in openai_clients:
|
||||||
client: openai.OpenAI = openai.OpenAI(
|
client: openai.OpenAI = openai.OpenAI(
|
||||||
api_key=openai_api_key or os.getenv("OPENAI_API_KEY"),
|
api_key=openai_api_key,
|
||||||
base_url=api_base_url,
|
base_url=api_base_url,
|
||||||
)
|
)
|
||||||
openai_clients[client_key] = client
|
openai_clients[client_key] = client
|
||||||
|
|||||||
Reference in New Issue
Block a user