-
Notifications
You must be signed in to change notification settings - Fork 139
Migrate from deprecated AzureOpenAI to standard OpenAI client constructors #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
ManagedIdentityCredential, | ||
get_bearer_token_provider, | ||
) | ||
from openai import AsyncAzureOpenAI | ||
from openai import AsyncOpenAI | ||
from quart import ( | ||
Blueprint, | ||
Response, | ||
|
@@ -47,11 +47,10 @@ async def configure_openai(): | |
if not os.getenv("AZURE_OPENAI_CHAT_DEPLOYMENT"): | ||
raise ValueError("AZURE_OPENAI_CHAT_DEPLOYMENT is required for Azure OpenAI") | ||
|
||
# Create the Asynchronous Azure OpenAI client | ||
bp.openai_client = AsyncAzureOpenAI( | ||
api_version=os.getenv("AZURE_OPENAI_API_VERSION") or "2024-02-15-preview", | ||
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"), | ||
azure_ad_token_provider=token_provider, | ||
# Create the Asynchronous OpenAI client | ||
bp.openai_client = AsyncOpenAI( | ||
base_url=os.getenv("AZURE_OPENAI_ENDPOINT"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This URL needs "/openai/v1" at the end |
||
api_key=token_provider, | ||
) | ||
# Set the model name to the Azure OpenAI model deployment name | ||
bp.openai_model = os.getenv("AZURE_OPENAI_CHAT_DEPLOYMENT") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile pyproject.toml | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile --output-file=src/requirements.txt src/pyproject.toml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change shouldnt be needed, as long as you run the file from inside the src folder There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an AGENTS.md that shows how to run pip-compile from inside the src folder |
||
# | ||
aiofiles==24.1.0 | ||
# via quart | ||
aiohappyeyeballs==2.6.1 | ||
# via aiohttp | ||
aiohttp==3.12.15 | ||
# via quartapp (pyproject.toml) | ||
aiohttp==3.12.15 | ||
# via quartapp (src/pyproject.toml) | ||
aiosignal==1.4.0 | ||
# via aiohttp | ||
annotated-types==0.7.0 | ||
|
@@ -24,7 +24,7 @@ attrs==25.3.0 | |
azure-core==1.35.1 | ||
# via azure-identity | ||
azure-identity==1.25.0 | ||
# via quartapp (pyproject.toml) | ||
# via quartapp (src/pyproject.toml) | ||
blinker==1.9.0 | ||
# via | ||
# flask | ||
|
@@ -57,26 +57,26 @@ frozenlist==1.7.0 | |
# aiohttp | ||
# aiosignal | ||
gunicorn==23.0.0 | ||
# via quartapp (pyproject.toml) | ||
# via quartapp (src/pyproject.toml) | ||
h11==0.16.0 | ||
# via | ||
# httpcore | ||
# hypercorn | ||
# uvicorn | ||
# wsproto | ||
h2==4.3.0 | ||
# via hypercorn | ||
hpack==4.1.0 | ||
h2==4.3.0 | ||
# via hypercorn | ||
hpack==4.1.0 | ||
# via h2 | ||
httpcore==1.0.9 | ||
# via httpx | ||
httptools==0.6.4 | ||
# via quartapp (pyproject.toml) | ||
httpx==0.28.1 | ||
# via quartapp (src/pyproject.toml) | ||
httpx==0.28.1 | ||
# via openai | ||
hypercorn==0.17.3 | ||
# via quart | ||
hyperframe==6.1.0 | ||
hyperframe==6.1.0 | ||
# via h2 | ||
idna==3.10 | ||
# via | ||
|
@@ -110,13 +110,13 @@ multidict==6.6.4 | |
# via | ||
# aiohttp | ||
# yarl | ||
openai==1.107.2 | ||
# via quartapp (pyproject.toml) | ||
openai==1.109.0 | ||
# via quartapp (src/pyproject.toml) | ||
packaging==25.0 | ||
# via gunicorn | ||
priority==2.0.0 | ||
# via hypercorn | ||
propcache==0.3.2 | ||
propcache==0.3.2 | ||
# via | ||
# aiohttp | ||
# yarl | ||
|
@@ -126,16 +126,16 @@ pydantic==2.11.9 | |
# via openai | ||
pydantic-core==2.33.2 | ||
# via pydantic | ||
pyjwt[crypto]==2.10.1 | ||
# via | ||
# msal | ||
# pyjwt | ||
python-dotenv==1.1.1 | ||
# via quartapp (pyproject.toml) | ||
pyjwt[crypto]==2.10.1 | ||
# via | ||
# msal | ||
# pyjwt | ||
python-dotenv==1.1.1 | ||
# via quartapp (src/pyproject.toml) | ||
pyyaml==6.0.2 | ||
# via quartapp (pyproject.toml) | ||
# via quartapp (src/pyproject.toml) | ||
quart==0.20.0 | ||
# via quartapp (pyproject.toml) | ||
# via quartapp (src/pyproject.toml) | ||
requests==2.32.5 | ||
# via | ||
# azure-core | ||
|
@@ -163,16 +163,16 @@ typing-inspection==0.4.1 | |
urllib3==2.5.0 | ||
# via requests | ||
uvicorn==0.36.0 | ||
# via quartapp (pyproject.toml) | ||
# via quartapp (src/pyproject.toml) | ||
uvloop==0.21.0 ; sys_platform != "win32" and (sys_platform != "cygwin" and platform_python_implementation != "PyPy") | ||
# via quartapp (pyproject.toml) | ||
# via quartapp (src/pyproject.toml) | ||
watchfiles==1.1.0 | ||
# via quartapp (pyproject.toml) | ||
# via quartapp (src/pyproject.toml) | ||
werkzeug==3.1.3 | ||
# via | ||
# flask | ||
# quart | ||
# quartapp (pyproject.toml) | ||
# quartapp (src/pyproject.toml) | ||
wsproto==1.2.0 | ||
# via hypercorn | ||
yarl==1.20.1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this from gitignore, no changes to gitignore should be needed