Skip to content

Commit

Permalink
audio/wav not audio/wave, refs #603
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Nov 13, 2024
1 parent 330e171 commit 7520671
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/plugins/advanced-model-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions llm/default_plugins/openai_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -327,7 +327,7 @@ def __init__(
if audio:
self.attachment_types.update(
{
"audio/wave",
"audio/wav",
"audio/mpeg",
}
)
Expand Down
7 changes: 3 additions & 4 deletions tests/test_cli_openai_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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()
Expand All @@ -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
)

0 comments on commit 7520671

Please sign in to comment.