Skip to content

Commit a0a3db7

Browse files
committed
Gemini hadles message.video of type Path
1 parent e965353 commit a0a3db7

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

llmlib/llmlib/gemini/gemini_code.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,10 @@ def dump_files_return_paths(msg: Message) -> list[Path]:
287287
msg.img.save(temp_file)
288288
paths.append(Path(temp_file))
289289
if msg.has_video():
290-
temp_file = tempfile.mktemp(suffix=".mp4")
291-
msg.video.save(temp_file)
292-
paths.append(Path(temp_file))
290+
if isinstance(msg.video, Path):
291+
paths.append(msg.video)
292+
else:
293+
temp_file = tempfile.mktemp(suffix=".mp4")
294+
msg.video.save(temp_file)
295+
paths.append(Path(temp_file))
293296
return paths

tests/test_gemini.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from pathlib import Path
2-
from llmlib.gemini.gemini_code import GeminiAPI, GeminiModels, SingleTurnRequest
1+
from llmlib.gemini.gemini_code import GeminiAPI, GeminiModels
32
import pytest
43

54
from tests.helpers import (
@@ -8,33 +7,10 @@
87
assert_model_recognizes_pyramid_in_image,
98
assert_model_supports_multiturn,
109
assert_model_supports_multiturn_with_file,
11-
file_for_test,
1210
is_ci,
1311
)
1412

1513

16-
@pytest.mark.skipif(condition=is_ci(), reason="Avoid costs")
17-
def test_gemini_vision():
18-
files: list[Path] = [
19-
file_for_test("pyramid.jpg"),
20-
file_for_test("mona-lisa.png"),
21-
file_for_test("some-audio.mp3"),
22-
]
23-
24-
for path in files:
25-
assert path.exists()
26-
27-
req = SingleTurnRequest(
28-
model_name=GeminiModels.gemini_20_flash,
29-
media_files=files,
30-
prompt="Describe this combined images/audio/text in detail.",
31-
)
32-
description: str = req.fetch_media_description().lower()
33-
assert "pyramid" in description
34-
assert "mona lisa" in description
35-
assert "horses are very fast" in description
36-
37-
3814
@pytest.mark.skipif(condition=is_ci(), reason="Avoid costs")
3915
def test_gemini_vision_using_interface():
4016
model = GeminiAPI(model_id=GeminiModels.gemini_20_flash_lite, max_output_tokens=50)

0 commit comments

Comments
 (0)