Skip to content

Commit

Permalink
Handle first chunk event
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd committed Oct 23, 2024
1 parent fdca4d9 commit 5c2d753
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion js/src/vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,21 @@ export class AISDKExporter {
return result;
})();

const events: KVMap[] = [];
if ("ai.response.msToFirstChunk" in span.attributes) {
events.push({
type: "first_chunk",
time: span.attributes["ai.response.msToFirstChunk"],
});
}

// TODO: add first_token_time
return asRunCreate({
run_type: "llm",
name: span.attributes["ai.model.provider"],
inputs,
outputs,
events,
extra: {
batch_size: 1,
metadata: {
Expand All @@ -466,7 +475,6 @@ export class AISDKExporter {
},
},
});
break;
}

case "ai.toolCall": {
Expand Down Expand Up @@ -540,11 +548,20 @@ export class AISDKExporter {
return result;
})();

const events: KVMap[] = [];
if ("ai.response.msToFirstChunk" in span.attributes) {
events.push({
type: "first_chunk",
time: span.attributes["ai.response.msToFirstChunk"],
});
}

return asRunCreate({
run_type: "llm",
name: span.attributes["ai.model.provider"],
inputs,
outputs,
events,
extra: {
batch_size: 1,
metadata: {
Expand Down

0 comments on commit 5c2d753

Please sign in to comment.