-
Notifications
You must be signed in to change notification settings - Fork 1.9k
bug: Warn about Azure OpenAI completions file-incompatibility #4048
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 2 commits
e37b0bc
91808ff
7cdf685
e6d4f06
9e0a102
5c45e72
cb6aa6b
17c6c25
63d7e6d
91b8337
a20068c
098f5ec
584a99d
61e4324
67c8371
caec194
ee4a419
b663951
aff00f3
22d356d
a10f9f1
f882fe8
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 |
|---|---|---|
|
|
@@ -118,7 +118,33 @@ Support for file URLs varies depending on type and provider: | |
| | [`MistralModel`][pydantic_ai.models.mistral.MistralModel] | `ImageUrl`, `DocumentUrl` (PDF) | — | `AudioUrl`, `VideoUrl`, `DocumentUrl` (non-PDF) | | ||
| | [`BedrockConverseModel`][pydantic_ai.models.bedrock.BedrockConverseModel] | S3 URLs (`s3://`) | `ImageUrl`, `DocumentUrl`, `VideoUrl` | `AudioUrl` | | ||
|
|
||
| A model API may be unable to download a file (e.g., because of crawling or access restrictions) even if it supports file URLs. For example, [`GoogleModel`][pydantic_ai.models.google.GoogleModel] on Vertex AI limits YouTube video URLs to one URL per request. In such cases, you can instruct Pydantic AI to download the file content locally and send that instead of the URL by setting `force_download` on the URL object: | ||
| ??? warning "`DocumentUrl` and `BinaryContent` documents are not supported when using `AzureProvider` with `OpenAIChatModel`." | ||
| Use [`OpenAIResponsesModel`][pydantic_ai.models.openai.OpenAIResponsesModel] with [`AzureProvider`][pydantic_ai.providers.azure.AzureProvider] instead: | ||
|
||
|
|
||
| ```python | ||
| from pydantic_ai import Agent, BinaryContent | ||
| from pydantic_ai.models.openai import OpenAIResponsesModel | ||
| from pydantic_ai.providers.azure import AzureProvider | ||
|
|
||
| pdf_bytes = b'%PDF-1.4 ...' # Your PDF content | ||
|
|
||
| model = OpenAIResponsesModel( | ||
| 'gpt-5', | ||
| provider=AzureProvider( | ||
| azure_endpoint='your-azure-endpoint', | ||
| api_version='your-api-version', | ||
| ), | ||
| ) | ||
| agent = Agent(model) | ||
| result = agent.run_sync([ | ||
| 'Summarize this document', | ||
| BinaryContent(data=pdf_bytes, media_type='application/pdf'), | ||
| ]) | ||
| ``` | ||
|
|
||
| A model API may be unable to download a file (e.g., because of crawling or access restrictions) even if it supports file URLs. For example, [`GoogleModel`][pydantic_ai.models.google.GoogleModel] on Vertex AI limits YouTube video URLs to one URL per request. | ||
|
|
||
| In such cases, you can instruct Pydantic AI to download the file content locally and send that instead of the URL by setting `force_download` on the URL object: | ||
dsfaccini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```py {title="force_download.py" test="skip" lint="skip"} | ||
| from pydantic_ai import ImageUrl, AudioUrl, VideoUrl, DocumentUrl | ||
|
|
||
|
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. 🚩 Potential bypass of document support check when In (Refers to line 1245) Was this helpful? React with 👍 or 👎 to provide feedback.
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. IMO the for future reference, if we found these inconsistencies, having a single dataclass that uses property to validate combinations would be a better approach than checking multiple flags, since adding a check branch here would bloat this out further |


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.
I'd rather add a Notes column to the table, like we have on the builtin tools doc, where we can state on the
OpenAIChatModelrow that Azure doesn't support it, and any other notes for provider-specific support (I believe there are some profile flags for specific providers that enable file types that are not supported by OpenAI itself)Uh oh!
There was an error while loading. Please reload this page.
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.
looking at my screen I'm not liking the idea of a fifth column

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.
Instead of adding a fifth column, what about mentioning the Azure case under "Unsupported", and then linking to the section that explains the responses workaround?