Skip to content

Fix missing audio file types in PrismMessages attachment conversion#247

Open
sulimanbenhalim wants to merge 1 commit intolaravel:0.xfrom
sulimanbenhalim:fix/audio-attachment-conversion
Open

Fix missing audio file types in PrismMessages attachment conversion#247
sulimanbenhalim wants to merge 1 commit intolaravel:0.xfrom
sulimanbenhalim:fix/audio-attachment-conversion

Conversation

@sulimanbenhalim
Copy link
Contributor

Supersedes #223

The four audio file types (Base64Audio, LocalAudio, RemoteAudio, StoredAudio) were missing from the match statement in fromLaravelAttachments() so passing any audio attachment into a conversation would throw an UnhandledMatchError at runtime

Images and documents worked fine, audio was just never added to the match

Before

$message = new UserMessage('Analyze this audio', attachments: collect([
    new Base64Audio(base64_encode(file_get_contents('audio.mp3')), 'audio/mpeg'),
]));

// UnhandledMatchError: Unhandled match case

After it converts cleanly to PrismAudio just like images convert to PrismImage

GPT-4o and Gemini both support audio as conversation input so this is a real use case not a theoretical one

Added tests in PrismMessagesTest covering all four audio types plus the existing image and document paths

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant