Skip to content

Commit

Permalink
Merge branch 'brynn/update-examples-to-openai-1x' into brynn/test-ope…
Browse files Browse the repository at this point in the history
…nai-1x
  • Loading branch information
brynn-code committed Nov 29, 2023
2 parents b42ed6f + a04ed9f commit 7290cee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions examples/flows/standard/basic-with-connection/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@ def get_client(connection: Union[CustomConnection, AzureOpenAIConnection]):
)

# connection can be extract as a dict object contains the configs and secrets
if isinstance(connection, CustomConnection):
connection_dict = dict(connection)
connection_dict = dict(connection)
api_key = connection_dict.get("api_key")
conn = dict(
api_key=api_key,
)
if api_key.startswith("sk-"):
from openai import OpenAI as Client
elif isinstance(connection, AzureOpenAIConnection):
from openai import AzureOpenAI as Client
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)}")
from openai import AzureOpenAI as Client
conn.update(
azure_endpoint=connection_dict.get("api_base"),
api_version=connection_dict.get("api_version", "2023-07-01-preview"),
)
return Client(**connection_dict)


Expand Down
2 changes: 1 addition & 1 deletion examples/flows/standard/gen-docstring/azure_open_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, **kwargs):
"using the command: pip install --upgrade openai."
)
init_params = {}
api_type = os.environ.get("OPENAI_API_TYPE")
api_type = os.environ.get("API_TYPE")
if os.getenv("OPENAI_API_VERSION") is not None:
init_params["api_version"] = os.environ.get("OPENAI_API_VERSION")
if os.getenv("OPENAI_ORG_ID") is not None:
Expand Down

0 comments on commit 7290cee

Please sign in to comment.