Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add all audio types supported by Gemini to AudioUrl#2151

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
DouweM merged 4 commits intopydantic:mainfromChenghaoMou:feat/add-more-audio-type
Jul 7, 2025

Conversation

ChenghaoMou
Copy link
Contributor

This should address#2143

Tested with the following code:

frompydantic_ai.models.geminiimportGeminiModelfrompydantic_ai.agentimportAgentfrompydantic_ai.messagesimportAudioUrl# from pydantic_ai.models.openai import OpenAIModelfromdotenvimportload_dotenvload_dotenv()asyncdefmain():# model = OpenAIModel("gpt-4.1-mini") AssertionError: Unsupported audio format: ...model=GeminiModel('gemini-2.0-flash')agent=Agent(model,instructions="You are a helpful assistant who can transcribe audio into text.")forsuffixin ["mp3","oga","aiff","aac","flac","wav"    ]:response=awaitagent.run(["What can you tell me about this audio?",AudioUrl(f"https://storage.googleapis.com/pydantic-pr-audio-url-testing-gemini/sample-0.{suffix}",force_download=True)        ])print(response.output)if__name__=="__main__":importasyncioasyncio.run(main())

The url should be public and available until this is merged.

@DouweM
Copy link
Contributor

@ChenghaoMou Thanks! Can you please runmake format to fix the linting issues, and update the test here?

@pytest.mark.parametrize(
'audio_url,media_type,format',
[
pytest.param(AudioUrl('foobar.mp3'),'audio/mpeg','mp3',id='mp3'),
pytest.param(AudioUrl('foobar.wav'),'audio/wav','wav',id='wav'),
],
)
deftest_audio_url(audio_url:AudioUrl,media_type:str,format:str):
assertaudio_url.media_type==media_type
assertaudio_url.format==format

@ChenghaoMou
Copy link
ContributorAuthor

@ChenghaoMou Thanks! Can you please runmake format to fix the linting issues, and update the test here?

@pytest.mark.parametrize(
'audio_url,media_type,format',
[
pytest.param(AudioUrl('foobar.mp3'),'audio/mpeg','mp3',id='mp3'),
pytest.param(AudioUrl('foobar.wav'),'audio/wav','wav',id='wav'),
],
)
deftest_audio_url(audio_url:AudioUrl,media_type:str,format:str):
assertaudio_url.media_type==media_type
assertaudio_url.format==format

@DouweM Thanks for the review! I have now made sure it passed

  • pre-commit hooks
  • make test
  • make format
  • make lint
  • make typecheck-mypy and make typecheck (This is why I think there are many if statements in that file because pyright doesn't like returning potentialstr instead ofLiteral values and why I resort back to if statements for consistency)

@DouweMDouweM changed the titleAdd more audio type in AudioUrlAdd all audio types supported by Gemini to AudioUrlJul 7, 2025
@DouweMDouweM merged commit72970c2 intopydantic:mainJul 7, 2025
18 checks passed
@DouweM
Copy link
Contributor

@ChenghaoMou Thank you!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees

@DouweMDouweM

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ChenghaoMou@DouweM

[8]ページ先頭

©2009-2025 Movatter.jp