This commit is contained in:
Timothy Jaeryang Baek
2026-08-25 11:07:54 -04:00
parent 6330350a40
commit ca4e07a40b
2 changed files with 26 additions and 4 deletions
+15 -2
View File
@@ -1359,8 +1359,21 @@ def convert_to_responses_payload(payload: dict) -> dict:
content_parts.append({'type': text_type, 'text': part.get('text', '')})
elif part.get('type') == 'image_url':
url_data = part.get('image_url', {})
url = url_data.get('url', '') if isinstance(url_data, dict) else url_data
content_parts.append({'type': 'input_image', 'image_url': url})
if isinstance(url_data, dict):
url = url_data.get('url', '')
detail = url_data.get('detail') or 'auto'
else:
url = url_data if isinstance(url_data, str) else ''
detail = 'auto'
content_parts.append({'type': 'input_image', 'image_url': url, 'detail': detail})
elif part.get('type') == 'file':
# OpenAI-compatible proxy path only. Open WebUI attachments are handled
# separately via metadata.files/RAG and must not be converted here.
file = part.get('file')
if isinstance(file, dict):
file_part = {k: file[k] for k in ('file_id', 'file_data', 'filename') if k in file}
if 'file_id' in file_part or 'file_data' in file_part:
content_parts.append({'type': 'input_file', **file_part})
else:
content_parts = [{'type': text_type, 'text': str(content)}]