generated from john/python-template
Continue GC code review and cleanup
This commit is contained in:
@@ -120,6 +120,7 @@ class TestOpenRouterProviderTranscribe:
|
||||
|
||||
assert result.text == "Line 1\nLine 2"
|
||||
assert result.provider == "openrouter"
|
||||
assert result.prompt_name is None
|
||||
assert result.model == "vendor/model-b"
|
||||
assert result.ai_metadata == {
|
||||
"finish_reason": "stop",
|
||||
@@ -142,6 +143,27 @@ class TestOpenRouterProviderTranscribe:
|
||||
mime_type="image/png",
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_sends_pdf_as_file_content(self):
|
||||
"""PDF payloads use OpenRouter's file content contract."""
|
||||
response = {"model": "vendor/model-a", "choices": [{"message": {"content": "Transcript text"}}]}
|
||||
client = _FakeClient(response=response)
|
||||
provider = OpenRouterTranscriptionProvider(
|
||||
settings=Settings(openrouter_api_key="test-key"),
|
||||
client=client,
|
||||
)
|
||||
|
||||
await provider.transcribe(
|
||||
prompt_text="Prompt body",
|
||||
image_bytes=b"pdf-bytes",
|
||||
mime_type="application/pdf",
|
||||
)
|
||||
|
||||
content = client.chat.calls[0]["messages"][0]["content"]
|
||||
assert content[1]["type"] == "file"
|
||||
assert content[1]["file"]["filename"] == "source.pdf"
|
||||
assert content[1]["file"]["file_data"].startswith("data:application/pdf;base64,")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_raises_on_empty_or_invalid_response(self):
|
||||
"""Transcribe raises ProviderResponseError for missing completion text."""
|
||||
|
||||
Reference in New Issue
Block a user