From a562949954bf639fb3d640e984dfdee9be5cee4c Mon Sep 17 00:00:00 2001 From: jwlee64 Date: Thu, 12 Dec 2024 15:11:14 -0800 Subject: [PATCH 1/2] add icons to trace tree --- .../PlaygroundChat/PlaygroundCallStats.tsx | 53 ++++++++++--------- .../pages/PlaygroundPage/PlaygroundPage.tsx | 24 +++++++-- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundCallStats.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundCallStats.tsx index 9888ea886819..f060d6859a77 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundCallStats.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundCallStats.tsx @@ -1,31 +1,19 @@ import {Button} from '@wandb/weave/components/Button'; +import {Pill} from '@wandb/weave/components/Tag'; import {Tailwind} from '@wandb/weave/components/Tailwind'; +import {Tooltip} from '@wandb/weave/components/Tooltip'; import {makeRefCall} from '@wandb/weave/util/refs'; import React from 'react'; import {useHistory} from 'react-router-dom'; import {useWeaveflowRouteContext} from '../../../context'; import {Reactions} from '../../../feedback/Reactions'; +import {TraceCostStats} from '../../CallPage/cost'; import {TraceCallSchema} from '../../wfReactInterface/traceServerClientTypes'; export const PlaygroundCallStats = ({call}: {call: TraceCallSchema}) => { - let totalTokens = 0; - if (call?.summary?.usage) { - for (const key of Object.keys(call.summary.usage)) { - totalTokens += - call.summary.usage[key].prompt_tokens || - call.summary.usage[key].input_tokens || - 0; - totalTokens += - call.summary.usage[key].completion_tokens || - call.summary.usage[key].output_tokens || - 0; - } - } - const [entityName, projectName] = call?.project_id?.split('/') || []; const callId = call?.id || ''; - const latency = call?.summary?.weave?.latency_ms; const {peekingRouter} = useWeaveflowRouteContext(); const history = useHistory(); @@ -43,21 +31,34 @@ export const PlaygroundCallStats = ({call}: {call: TraceCallSchema}) => { false ); + const latency = call?.summary?.weave?.latency_ms ?? 0; + const usageData = call?.summary?.usage; + const costData = call?.summary?.weave?.costs; + return ( -
- Latency: {latency}ms - +
+ {(call.output as any)?.choices?.[0]?.finish_reason && ( - <> - - Finish reason: {(call.output as any).choices[0].finish_reason} - - - + + + + } + /> )} - {totalTokens} tokens - {callLink && (