Skip to content

Commit 82a3e50

Browse files
committed
Fixing llm example
1 parent 76963e5 commit 82a3e50

File tree

1 file changed

+6
-2
lines changed
  • docs/platforms/javascript/common/tracing/span-metrics

1 file changed

+6
-2
lines changed

docs/platforms/javascript/common/tracing/span-metrics/examples.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,6 @@ app.post('/api/ai/chat', async (req: Request, res: Response) => {
693693
let totalTokens = 0;
694694
let toolsUsed: string[] = [];
695695
let finalResponse = '';
696-
let resolutionStatus = 'in_progress';
697696

698697
// Step 1: Call custom LLM for initial reasoning
699698
const llmResponse = await Sentry.startSpan(
@@ -762,15 +761,20 @@ app.post('/api/ai/chat', async (req: Request, res: Response) => {
762761

763762
// Set final agent attributes
764763
finalResponse = llmResponse.choices[0].message.content;
764+
const resolutionStatus = toolsUsed.length > 0 ? 'resolved' : 'answered';
765+
765766
agentSpan.setAttribute('gen_ai.response.text', finalResponse);
767+
agentSpan.setAttribute('gen_ai.response.id', llmResponse.id);
766768
agentSpan.setAttribute('gen_ai.usage.total_tokens', totalTokens);
767769
agentSpan.setAttribute('conversation.tools_used', JSON.stringify(toolsUsed));
768-
agentSpan.setAttribute('conversation.resolution_status', toolsUsed.length > 0 ? 'resolved' : 'answered');
770+
agentSpan.setAttribute('conversation.resolution_status', resolutionStatus);
769771

770772
res.json({
771773
message: finalResponse,
774+
responseId: llmResponse.id,
772775
totalTokens,
773776
toolsUsed,
777+
resolutionStatus,
774778
});
775779

776780
} catch (error) {

0 commit comments

Comments
 (0)