File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
pdl-live-react/src/view/detail Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,15 @@ import { Tab, TabTitleText } from "@patternfly/react-core"
33
44const BlockNotFound = lazy ( ( ) => import ( "./BlockNotFound" ) )
55const DefContent = lazy ( ( ) => import ( "./DefContent" ) )
6+ const UsageTabContent = lazy ( ( ) => import ( "./UsageTabContent" ) )
67const SourceTabContent = lazy ( ( ) => import ( "./SourceTabContent" ) )
78const ContextTabContent = lazy ( ( ) => import ( "./ContextTabContent" ) )
89const SummaryTabContent = lazy ( ( ) => import ( "./SummaryTabContent" ) )
910const RawTraceTabContent = lazy ( ( ) => import ( "./RawTraceTabContent" ) )
1011
1112import {
1213 hasContextInformation ,
14+ hasModelUsage ,
1315 hasResult ,
1416 type NonScalarPdlBlock as Model ,
1517} from "../../helpers"
@@ -54,6 +56,18 @@ function blockBody(block: Model) {
5456 )
5557 }
5658
59+ if ( hasModelUsage ( block ) ) {
60+ tabs . splice (
61+ 1 ,
62+ 0 ,
63+ < Tab key = { 4 } eventKey = { 4 } title = { < TabTitleText > Usage</ TabTitleText > } >
64+ < Suspense >
65+ < UsageTabContent block = { block } />
66+ </ Suspense >
67+ </ Tab > ,
68+ )
69+ }
70+
5771 return tabs
5872}
5973
Original file line number Diff line number Diff line change 1+ import {
2+ DescriptionList ,
3+ DescriptionListGroup ,
4+ DescriptionListDescription ,
5+ DescriptionListTerm ,
6+ } from "@patternfly/react-core"
7+
8+ import type { ModelBlockWithUsage , PdlBlockWithTiming } from "../../helpers"
9+
10+ export default function UsageTabContent ( {
11+ block,
12+ } : {
13+ block : ModelBlockWithUsage & PdlBlockWithTiming
14+ } ) {
15+ return < DescriptionList > { descriptionItems ( block ) } </ DescriptionList >
16+ }
17+
18+ function descriptionItems ( block : ModelBlockWithUsage & PdlBlockWithTiming ) {
19+ return (
20+ < >
21+ < DescriptionListGroup >
22+ < DescriptionListTerm > Rate of Model Execution</ DescriptionListTerm >
23+ < DescriptionListDescription >
24+ { (
25+ ( block . pdl__usage . completion_tokens +
26+ block . pdl__usage . prompt_tokens ) /
27+ ( ( block . pdl__timing . end_nanos - block . pdl__timing . start_nanos ) /
28+ 1000000000 )
29+ ) . toFixed ( 0 ) } { " " }
30+ tokens/sec
31+ </ DescriptionListDescription >
32+ </ DescriptionListGroup >
33+
34+ < DescriptionListGroup >
35+ < DescriptionListTerm > Completion Tokens Consumed</ DescriptionListTerm >
36+ < DescriptionListDescription >
37+ { block . pdl__usage . completion_tokens }
38+ </ DescriptionListDescription >
39+ </ DescriptionListGroup >
40+
41+ < DescriptionListGroup >
42+ < DescriptionListTerm > Prompt Tokens Consumed</ DescriptionListTerm >
43+ < DescriptionListDescription >
44+ { block . pdl__usage . prompt_tokens }
45+ </ DescriptionListDescription >
46+ </ DescriptionListGroup >
47+ </ >
48+ )
49+ }
You can’t perform that action at this time.
0 commit comments