mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-20 05:11:48 +00:00
fix(proxy): stringify tool_result images for OpenAI upstreams
This commit is contained in:
1 parent
b33277bf93
commit
f6bb31c956
2 files changed
+45
-22
No files matched your search
@@ -219,7 +219,18 @@ function convertToolResultContent(content: unknown, isError: boolean, label: str
|
||||
}
|
||||
|
||||
if (parsed.type === 'image') {
|
||||
throw new Error(`${label}[${index}].type "image" is not supported in tool_result content`);
|
||||
const source =
|
||||
typeof parsed.source === 'object' && parsed.source !== null
|
||||
? (parsed.source as Record<string, unknown>)
|
||||
: undefined;
|
||||
const description =
|
||||
source?.type === 'url' && typeof source.url === 'string'
|
||||
? source.url
|
||||
: source?.type === 'base64' && typeof source.media_type === 'string'
|
||||
? `${source.media_type} base64 payload`
|
||||
: 'unsupported image payload';
|
||||
parts.push(`[tool_result image omitted: ${description}]`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof parsed.text === 'string') {
|
||||
|
||||
Reference in new issue
Block a user