Unverified Commit 2b157d89 authored by Tanmay Verma's avatar Tanmay Verma Committed by GitHub
Browse files

fix: Allow requests to include audio contents before text (#5143)

parent 6be9c9a4
...@@ -204,11 +204,15 @@ class Processor(ProcessMixIn): ...@@ -204,11 +204,15 @@ class Processor(ProcessMixIn):
if "<prompt>" not in template: if "<prompt>" not in template:
raise ValueError("prompt_template must contain '<prompt>' placeholder") raise ValueError("prompt_template must contain '<prompt>' placeholder")
# Safely extract user text # Safely extract user text - find the text content item
try: user_text = None
user_text = raw_request.messages[0].content[0].text for message in raw_request.messages:
except (IndexError, AttributeError) as e: for item in message.content:
raise ValueError(f"Invalid message structure: {e}") if item.type == "text":
user_text = item.text
break
if user_text is None:
raise ValueError("No text content found in the request messages")
prompt = template.replace("<prompt>", user_text) prompt = template.replace("<prompt>", user_text)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment