-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
style(weave): add icons to trace tree #3227
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Tailwind> | ||
<div className="flex w-full flex-wrap items-center justify-center gap-8 py-8 text-sm text-moon-500"> | ||
<span>Latency: {latency}ms</span> | ||
<span>•</span> | ||
<div className="flex w-full items-center justify-center gap-8 py-8"> | ||
<TraceCostStats | ||
usageData={usageData} | ||
costData={costData} | ||
latency_ms={latency} | ||
costLoading={false} | ||
/> | ||
{(call.output as any)?.choices?.[0]?.finish_reason && ( | ||
<> | ||
<span> | ||
Finish reason: {(call.output as any).choices[0].finish_reason} | ||
</span> | ||
<span>•</span> | ||
</> | ||
<Tooltip | ||
content="Finish Reason" | ||
trigger={ | ||
<span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a Pill renders a div, so this should probably be a block level element like div too. |
||
<Pill | ||
icon="checkmark-circle" | ||
label={(call.output as any).choices[0].finish_reason} | ||
color="moon" | ||
className="-ml-[8px] bg-transparent text-moon-500 dark:bg-transparent dark:text-moon-500" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know you could write the negative margin that way in Tailwind, I think I've always done it |
||
/> | ||
</span> | ||
} | ||
/> | ||
)} | ||
<span>{totalTokens} tokens</span> | ||
<span>•</span> | ||
{callLink && ( | ||
<Button | ||
size="small" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Cool. TY! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer sentence case