Skip to content

Commit

Permalink
Fix: organization error
Browse files Browse the repository at this point in the history
  • Loading branch information
luyaxi committed Nov 25, 2023
1 parent 4d60a06 commit 312c0b2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions XAgent/ai_functions/request/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,28 @@ def chatcompletion_request(**kwargs):
azure_endpoint = chatcompletion_kwargs.pop("azure_endpoint", None)
api_version = chatcompletion_kwargs.pop("api_version", None)
api_key = chatcompletion_kwargs.pop("api_key", None)
organization = chatcompletion_kwargs.pop("organization", None)
chatcompletion_kwargs.update(kwargs)
client = openai.AzureOpenAI(
api_key=api_key, azure_endpoint=azure_endpoint, api_version=api_version, timeout=request_timeout
api_key=api_key,
organization=organization,
azure_endpoint=azure_endpoint,
api_version=api_version,
timeout=request_timeout
)
else:
if "base_url" in chatcompletion_kwargs:
base_url = chatcompletion_kwargs.pop("base_url", None)
else:
base_url = chatcompletion_kwargs.pop("api_base", None)
api_key = chatcompletion_kwargs.pop("api_key", None)
organization = chatcompletion_kwargs.pop("organization", None)
chatcompletion_kwargs.update(kwargs)
client = openai.OpenAI(
api_key=api_key, base_url=base_url, timeout=request_timeout
api_key=api_key,
organization=organization,
base_url=base_url,
timeout=request_timeout
)
try:
completions = client.chat.completions.create(**chatcompletion_kwargs)
Expand Down

0 comments on commit 312c0b2

Please sign in to comment.