-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Support FileUrl.force_download in AnthropicModel and OpenAIResponsesModel
#3694
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
c642ac7
review multi modal input handling
dsfaccini 754c0f0
enable url media for openai responses
dsfaccini 2f5bcf6
Update documentation for BinaryContent.base64 usage
dsfaccini 5d99ed2
Merge branch 'main' into review-multimodal
dsfaccini ff5d79a
Merge branch 'main' into review-multimodal
dsfaccini 887a79f
Merge branch 'main' into review-multimodal
dsfaccini 6bba553
Address review comments: force_download, type rename, refactoring
dsfaccini 7389467
upstream cerebras merge stuff
dsfaccini 8ad810d
AsyncClient
dsfaccini da9ec78
base64 replacements
dsfaccini 9a55ce2
add force download support for mistral
dsfaccini 703b772
address review comments
dsfaccini 35d8745
update docs
dsfaccini d9e8a01
allow explicit download disallowing
dsfaccini 0bcd2e8
Merge remote-tracking branch 'origin/main' into review-multimodal
dsfaccini 8a98f77
fix linting issue and update doc
dsfaccini 45d35e5
fix tests
dsfaccini 4a6234d
undo tri-optional force download and remove experiments folder
dsfaccini 13c5284
include suggestion
dsfaccini 91b1f79
include suggestion
dsfaccini 0688875
Merge remote-tracking branch 'upstream/main' into review-multimodal
dsfaccini eab1e14
requested changes
dsfaccini 6e0b72d
fix tests
dsfaccini 532103a
Merge branch 'main' into review-multimodal
dsfaccini a5b8f2d
fix docs
dsfaccini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,7 +199,46 @@ agent = Agent(model) | |
|
|
||
| ## Document, Image, Audio, and Video Input | ||
|
|
||
| `GoogleModel` supports multi-modal input, including documents, images, audio, and video. See the [input documentation](../input.md) for details and examples. | ||
| `GoogleModel` supports multi-modal input, including documents, images, audio, and video. | ||
|
|
||
| YouTube video URLs can be passed directly to Google models: | ||
|
Collaborator
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. If we make this edit, I think we should add the Files API example from input.md "Uploaded Files" as well |
||
|
|
||
| ```py {title="youtube_input.py" test="skip" lint="skip"} | ||
| from pydantic_ai import Agent, VideoUrl | ||
| from pydantic_ai.models.google import GoogleModel | ||
|
|
||
| agent = Agent(GoogleModel('gemini-2.5-flash')) | ||
| result = agent.run_sync( | ||
| [ | ||
| 'What is this video about?', | ||
| VideoUrl(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ'), | ||
| ] | ||
| ) | ||
| print(result.output) | ||
| ``` | ||
|
|
||
| Files can be uploaded via the [Files API](https://ai.google.dev/gemini-api/docs/files) and passed as URLs: | ||
|
|
||
| ```py {title="file_upload.py" test="skip"} | ||
| from pydantic_ai import Agent, DocumentUrl | ||
| from pydantic_ai.models.google import GoogleModel | ||
| from pydantic_ai.providers.google import GoogleProvider | ||
|
|
||
| provider = GoogleProvider() | ||
| file = provider.client.files.upload(file='pydantic-ai-logo.png') | ||
| assert file.uri is not None | ||
|
|
||
| agent = Agent(GoogleModel('gemini-2.5-flash', provider=provider)) | ||
| result = agent.run_sync( | ||
| [ | ||
| 'What company is this logo from?', | ||
| DocumentUrl(url=file.uri, media_type=file.mime_type), | ||
| ] | ||
| ) | ||
| print(result.output) | ||
| ``` | ||
|
|
||
| See the [input documentation](../input.md) for more details and examples. | ||
|
|
||
| ## Model settings | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.