Skip to content

Commit

Permalink
Merge pull request microsoft#121 from AL-377/Jack-Q/openai-config-fix
Browse files Browse the repository at this point in the history
fix openai config
  • Loading branch information
vyokky authored Aug 23, 2024
2 parents 9d0329d + 9c9ef76 commit 69e3e1f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ufo/llm/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def __init__(self, config, agent_type: str) -> None:
self.config_llm["API_BASE"],
self.max_retry,
self.config["TIMEOUT"],
self.config_llm.get("API_KEY"),
self.config_llm.get("API_VERSION"),
self.config_llm.get("API_KEY", ""),
self.config_llm.get("API_VERSION", ""),
aad_api_scope_base = self.config_llm.get("AAD_API_SCOPE_BASE", ""),
aad_tenant_id = self.config_llm.get("AAD_TENANT_ID", ""),
)
Expand Down Expand Up @@ -144,14 +144,18 @@ def get_openai_client(
aad_tenant_id: Optional[str] = None,
) -> OpenAI:
if api_type == "openai":
assert api_key, "OpenAI API key must be specified"
assert api_base, "OpenAI API base URL must be specified"
client = OpenAI(
base_url=api_base,
api_key=api_key,
max_retries=max_retry,
timeout=timeout,
)
else:
if api_key:
assert api_version, "Azure OpenAI API version must be specified"
if api_type == "aoai":
assert api_key, "Azure OpenAI API key must be specified"
client = AzureOpenAI(
max_retries=max_retry,
timeout=timeout,
Expand Down

0 comments on commit 69e3e1f

Please sign in to comment.