From 7520671176ad24680632b47138862c2c548a9368 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 12 Nov 2024 21:11:05 -0800 Subject: [PATCH] audio/wav not audio/wave, refs #603 --- docs/plugins/advanced-model-plugins.md | 2 +- docs/usage.md | 2 +- llm/default_plugins/openai_models.py | 4 ++-- tests/test_cli_openai_models.py | 7 +++---- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/plugins/advanced-model-plugins.md b/docs/plugins/advanced-model-plugins.md index a201237c..b9a16885 100644 --- a/docs/plugins/advanced-model-plugins.md +++ b/docs/plugins/advanced-model-plugins.md @@ -79,7 +79,7 @@ def _attachment(attachment): if attachment.resolve_type().startswith("image/"): return {"type": "image_url", "image_url": {"url": url}} else: - format_ = "wav" if attachment.resolve_type() == "audio/wave" else "mp3" + format_ = "wav" if attachment.resolve_type() == "audio/wav" else "mp3" return { "type": "input_audio", "input_audio": { diff --git a/docs/usage.md b/docs/usage.md index 564e4382..dd44ff10 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -305,7 +305,7 @@ OpenAI Chat: gpt-4o-audio-preview seed: int json_object: boolean Attachment types: - audio/mpeg, audio/wave + audio/mpeg, audio/wav OpenAI Chat: gpt-3.5-turbo (aliases: 3.5, chatgpt) Options: temperature: float diff --git a/llm/default_plugins/openai_models.py b/llm/default_plugins/openai_models.py index d7e29e05..cc68df03 100644 --- a/llm/default_plugins/openai_models.py +++ b/llm/default_plugins/openai_models.py @@ -263,7 +263,7 @@ def _attachment(attachment): if attachment.resolve_type().startswith("image/"): return {"type": "image_url", "image_url": {"url": url}} else: - format_ = "wav" if attachment.resolve_type() == "audio/wave" else "mp3" + format_ = "wav" if attachment.resolve_type() == "audio/wav" else "mp3" return { "type": "input_audio", "input_audio": { @@ -327,7 +327,7 @@ def __init__( if audio: self.attachment_types.update( { - "audio/wave", + "audio/wav", "audio/mpeg", } ) diff --git a/tests/test_cli_openai_models.py b/tests/test_cli_openai_models.py index f341e385..7cbab726 100644 --- a/tests/test_cli_openai_models.py +++ b/tests/test_cli_openai_models.py @@ -65,9 +65,8 @@ def test_only_gpt4_audio_preview_allows_mp3_or_wav(httpx_mock, model, filetype): method="HEAD", url=f"https://www.example.com/example.{filetype}", content=b"binary-data", - headers={"Content-Type": "audio/mpeg" if filetype == "mp3" else "audio/wave"}, + headers={"Content-Type": "audio/mpeg" if filetype == "mp3" else "audio/wav"}, ) - # Another mock for the correct model if model == "gpt-4o-audio-preview": httpx_mock.add_response( method="POST", @@ -116,7 +115,7 @@ def test_only_gpt4_audio_preview_allows_mp3_or_wav(httpx_mock, model, filetype): url=f"https://www.example.com/example.{filetype}", content=b"binary-data", headers={ - "Content-Type": "audio/mpeg" if filetype == "mp3" else "audio/wave" + "Content-Type": "audio/mpeg" if filetype == "mp3" else "audio/wav" }, ) runner = CliRunner() @@ -140,7 +139,7 @@ def test_only_gpt4_audio_preview_allows_mp3_or_wav(httpx_mock, model, filetype): ) else: assert result.exit_code == 1 - long = "audio/mpeg" if filetype == "mp3" else "audio/wave" + long = "audio/mpeg" if filetype == "mp3" else "audio/wav" assert ( f"This model does not support attachments of type '{long}'" in result.output )