Skip to content

Commit 90c2106

Browse files
committed
Gemini Video Support
1 parent 22734e2 commit 90c2106

File tree

5 files changed

+59952
-4
lines changed

5 files changed

+59952
-4
lines changed

docs/input.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ You can provide audio input using either [`AudioUrl`][pydantic_ai.AudioUrl] or [
5555
## Video Input
5656

5757
!!! info
58-
Some models do not support video input. Please check the model's documentation to confirm whether it supports audio input.
58+
Some models do not support video input. Please check the model's documentation to confirm whether it supports video input.
5959

6060
You can provide video input using either [`VideoUrl`][pydantic_ai.VideoUrl] or [`BinaryContent`][pydantic_ai.BinaryContent]. The process is analogous to the examples above.
6161

pydantic_ai_slim/pydantic_ai/models/gemini.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ async def _map_user_prompt(self, part: UserPromptPart) -> list[_GeminiPartUnion]
328328
content.append(
329329
_GeminiInlineDataPart(inline_data={'data': base64_encoded, 'mime_type': item.media_type})
330330
)
331-
elif isinstance(item, (AudioUrl, ImageUrl, DocumentUrl)):
331+
elif isinstance(item, (AudioUrl, ImageUrl, DocumentUrl, VideoUrl)):
332332
client = cached_async_http_client()
333333
response = await client.get(item.url, follow_redirects=True)
334334
response.raise_for_status()
@@ -337,8 +337,6 @@ async def _map_user_prompt(self, part: UserPromptPart) -> list[_GeminiPartUnion]
337337
inline_data={'data': base64.b64encode(response.content).decode('utf-8'), 'mime_type': mime_type}
338338
)
339339
content.append(inline_data)
340-
elif isinstance(item, VideoUrl): # pragma: no cover
341-
raise NotImplementedError('VideoUrl is not supported for Gemini.')
342340
else:
343341
assert_never(item)
344342
return content

tests/models/cassettes/test_gemini/test_video_as_binary_content_input.yaml

+71
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)