mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 16:02:24 +00:00
Add image support in tool results across all providers
Tool results now use content blocks and can include both text and images. All providers (Anthropic, Google, OpenAI Completions, OpenAI Responses) correctly pass images from tool results to LLMs. - Update ToolResultMessage type to use content blocks - Add placeholder text for image-only tool results in Google/Anthropic - OpenAI providers send tool result + follow-up user message with images - Fix Anthropic JSON parsing for empty tool arguments - Add comprehensive tests for image-only and text+image tool results - Update README with tool result content blocks API
This commit is contained in:
parent
9dac37d836
commit
84dcab219b
37 changed files with 720 additions and 544 deletions
|
|
@ -244,7 +244,7 @@ export class TuiRenderer {
|
|||
assistantMsg.stopReason === "aborted" ? "Operation aborted" : assistantMsg.errorMessage || "Error";
|
||||
for (const [toolCallId, component] of this.pendingTools.entries()) {
|
||||
component.updateResult({
|
||||
output: errorMessage,
|
||||
content: [{ type: "text", text: errorMessage }],
|
||||
isError: true,
|
||||
});
|
||||
}
|
||||
|
|
@ -273,8 +273,12 @@ export class TuiRenderer {
|
|||
const component = this.pendingTools.get(event.toolCallId);
|
||||
if (component) {
|
||||
// Update the component with the result
|
||||
const content =
|
||||
typeof event.result === "string"
|
||||
? [{ type: "text" as const, text: event.result }]
|
||||
: event.result.content;
|
||||
component.updateResult({
|
||||
output: typeof event.result === "string" ? event.result : event.result.output,
|
||||
content,
|
||||
isError: event.isError,
|
||||
});
|
||||
this.pendingTools.delete(event.toolCallId);
|
||||
|
|
@ -358,7 +362,7 @@ export class TuiRenderer {
|
|||
? "Operation aborted"
|
||||
: assistantMsg.errorMessage || "Error";
|
||||
component.updateResult({
|
||||
output: errorMessage,
|
||||
content: [{ type: "text", text: errorMessage }],
|
||||
isError: true,
|
||||
});
|
||||
} else {
|
||||
|
|
@ -373,7 +377,7 @@ export class TuiRenderer {
|
|||
const component = this.pendingTools.get(toolResultMsg.toolCallId);
|
||||
if (component) {
|
||||
component.updateResult({
|
||||
output: toolResultMsg.output,
|
||||
content: toolResultMsg.content,
|
||||
isError: toolResultMsg.isError,
|
||||
});
|
||||
// Remove from pending map since it's complete
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue