Skip to content

Commit

Permalink
Improve rendering of intermediate tool calls
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd committed Oct 23, 2024
1 parent 73abeae commit 2c89549
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion js/src/vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,22 @@ export class AISDKExporter {

const outputs = ((): KVMap | undefined => {
let result: KVMap | undefined = undefined;

if (span.attributes["ai.response.toolCalls"]) {
let content = tryJson(span.attributes["ai.response.toolCalls"]);

if (Array.isArray(content)) {
content = content.map((i) => ({
type: "tool-call",
...i,
args: tryJson(i.args),
}));
}

result = {
llm_output: convertCoreToSmith({
role: "assistant",
content: tryJson(span.attributes["ai.response.toolCalls"]),
content,
} satisfies CoreAssistantMessage),
};
} else if (span.attributes["ai.response.text"]) {
Expand Down

0 comments on commit 2c89549

Please sign in to comment.