Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
Signed-off-by: Brynn Yin <[email protected]>
  • Loading branch information
brynn-code committed Nov 29, 2023
1 parent 869dd12 commit 927f997
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions examples/flows/standard/basic-with-connection/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ def get_client(connection: Union[CustomConnection, AzureOpenAIConnection]):
"Please upgrade your OpenAI package to version >= 1.0.0 or using the command: pip install --upgrade openai."
)
# connection can be extract as a dict object contains the configs and secrets
connection_dict = dict(connection)
if isinstance(connection, CustomConnection):
connection_dict = dict(connection)
from openai import OpenAI as Client
elif isinstance(connection, AzureOpenAIConnection):
from openai import AzureOpenAI as Client
connection_dict["azure_endpoint"] = connection.api_base
connection_dict.pop("api_base")
connection_dict.pop("api_type")
connection_dict = {
"azure_endpoint": connection.api_base,
"api_key": connection.api_key,
"api_version": connection.api_version,
}
else:
raise ValueError(f"Unsupported connection type {type(connection)}")
return Client(**connection_dict)
Expand Down

0 comments on commit 927f997

Please sign in to comment.