-
Notifications
You must be signed in to change notification settings - Fork 70
regression URL parsing in PR #231 #239
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
Changes from 4 commits
890cbd3
dc02a53
9d598ba
445cf63
d99086d
dd1e253
c92e938
feeaea2
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 |
|---|---|---|
|
|
@@ -195,9 +195,12 @@ def parse_azure_endpoint( | |
| f"{endpoint_envvar}={azure_endpoint} doesn't contain valid api-version field" | ||
| ) | ||
|
|
||
| # Strip query string — AsyncAzureOpenAI expects a clean base URL and | ||
| # receives api_version as a separate parameter. | ||
| # Strip query string and deployment path — AsyncAzureOpenAI expects a | ||
| # clean base URL and builds the deployment path internally. | ||
| clean_endpoint = azure_endpoint.split("?", 1)[0] | ||
| deployment_idx = clean_endpoint.find("/openai/deployments/") | ||
| if deployment_idx >= 0: | ||
| clean_endpoint = clean_endpoint[:deployment_idx] | ||
|
Contributor
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 handles Suggested addition after this line: # Also strip a bare /openai suffix — the SDK always appends /openai.
clean_endpoint = re.sub(r"/openai$", "", clean_endpoint)
Collaborator
Author
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. i think we should use: |
||
|
|
||
| return clean_endpoint, m.group(1) | ||
|
|
||
|
|
@@ -253,6 +256,7 @@ def create_async_openai_client( | |
| api_version=api_version, | ||
| azure_endpoint=azure_endpoint, | ||
| api_key=azure_api_key, | ||
| default_headers={"Ocp-Apim-Subscription-Key": azure_api_key}, | ||
| ) | ||
|
|
||
| else: | ||
|
|
@@ -264,6 +268,7 @@ def create_async_openai_client( | |
| # The true return type is pydantic_ai.Agent[T], but that's an optional dependency. | ||
| def make_agent[T](cls: type[T]): | ||
| """Create Pydantic AI agent using hardcoded preferences.""" | ||
| from openai import AsyncAzureOpenAI | ||
| from pydantic_ai import Agent, NativeOutput, ToolOutput | ||
| from pydantic_ai.models.openai import OpenAIChatModel | ||
| from pydantic_ai.providers.azure import AzureProvider | ||
|
bmerkle marked this conversation as resolved.
Outdated
|
||
|
|
@@ -285,9 +290,12 @@ def make_agent[T](cls: type[T]): | |
| model = OpenAIChatModel( | ||
| "gpt-4o", | ||
| provider=AzureProvider( | ||
| azure_endpoint=azure_endpoint, | ||
| api_version=api_version, | ||
| api_key=azure_api_key, | ||
| openai_client=AsyncAzureOpenAI( | ||
| azure_endpoint=azure_endpoint, | ||
| api_version=api_version, | ||
| api_key=azure_api_key, | ||
| default_headers={"Ocp-Apim-Subscription-Key": azure_api_key}, | ||
| ), | ||
| ), | ||
| ) | ||
|
bmerkle marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.