"use strict";(self.webpackChunk_mlflow_mlflow=self.webpackChunk_mlflow_mlflow||[]).push([[2841],{30618:function(e,t,o){o.d(t,{b:function(){return l}});var a=o(90970),i=o(15714),n=o(60719),r=o(49960),s=o(44941),l=(0,a.gu)({chartName:"LineChart",GraphicalChild:i.N,axisComponents:[{axisType:"xAxis",AxisComp:n.W},{axisType:"yAxis",AxisComp:r.h}],formatAxisMap:s.pr})},92841:function(e,t,o){o.d(t,{TraceTokenStatsChart:function(){return Y}});var a=o(68248),i=o(46709),n=o(27757),r=o(82716),s=o(40724),l=o(66774),d=o(30618),p=o(60719),c=o(49960),u=o(858),v=o(15714),m=o(97245),g=o(6581),h=o(54313),T=o(23327),y=o(83110),k=o(69983);var f=o(3409),M=o(73408);const Y=()=>{const{theme:e}=(0,n.u)(),t=(0,f.zZ)(),o=(0,f.IT)(),Y=(0,f.gy)(),{getOpacity:C,handleLegendMouseEnter:_,handleLegendMouseLeave:A}=(0,y.pH)(),{chartData:E,avgTokens:x,isLoading:L,error:N,hasData:D}=function(){var e,t,o;const{experimentId:a,startTimeMs:n,endTimeMs:r,timeIntervalSeconds:s,timeBuckets:l}=(0,k.W)(),{data:d,isLoading:p,error:c}=(0,T.o4)({experimentId:a,startTimeMs:n,endTimeMs:r,viewType:h.mW.TRACES,metricName:h.po.TOTAL_TOKENS,aggregations:[{aggregation_type:h.DF.PERCENTILE,percentile_value:h.a9},{aggregation_type:h.DF.PERCENTILE,percentile_value:h.CX},{aggregation_type:h.DF.PERCENTILE,percentile_value:h.Jq}],timeIntervalSeconds:s}),{data:u,isLoading:v,error:m}=(0,T.o4)({experimentId:a,startTimeMs:n,endTimeMs:r,viewType:h.mW.TRACES,metricName:h.po.TOTAL_TOKENS,aggregations:[{aggregation_type:h.DF.AVG}]}),g=(0,i.useMemo)(()=>(null===d||void 0===d?void 0:d.data_points)||[],[null===d||void 0===d?void 0:d.data_points]),f=p||v,M=c||m,Y=null===u||void 0===u||null===(e=u.data_points)||void 0===e||null===(t=e[0])||void 0===t||null===(o=t.values)||void 0===o?void 0:o[h.DF.AVG],C=(0,i.useCallback)(e=>{var t,o,a;return{p50:(null===(t=e.values)||void 0===t?void 0:t[(0,h.re)(h.a9)])||0,p90:(null===(o=e.values)||void 0===o?void 0:o[(0,h.re)(h.CX)])||0,p99:(null===(a=e.values)||void 0===a?void 0:a[(0,h.re)(h.Jq)])||0}},[]),_=(0,y.NM)(g,C);return{chartData:(0,i.useMemo)(()=>l.map(e=>{const t=_.get(e);return{name:(0,y.fq)(e,s),p50:(null===t||void 0===t?void 0:t.p50)||0,p90:(null===t||void 0===t?void 0:t.p90)||0,p99:(null===t||void 0===t?void 0:t.p99)||0}}),[l,_,s]),avgTokens:Y,isLoading:f,error:M,hasData:g.length>0}}(),I=(0,i.useCallback)((e,t)=>[(0,y.B4)(e),t],[]),w={p50:e.colors.green300,p90:e.colors.green500,p99:e.colors.yellow500};return L?(0,M.Y)(f.lh,{}):N?(0,M.Y)(f.nN,{}):(0,M.FD)(f.h,{componentId:"mlflow.charts.trace_token_stats",children:[(0,M.Y)(f.XQ,{icon:(0,M.Y)(r.BarChartIcon,{}),title:(0,M.Y)(s.A,{id:"IlYdrX",defaultMessage:"Tokens per Trace"}),value:void 0!==x?(0,y.B4)(Math.round(x)):void 0,subtitle:void 0!==x?(0,M.Y)(s.A,{id:"MXhKKt",defaultMessage:"avg per trace"}):void 0}),(0,M.Y)("div",{css:(0,a.AH)({height:f.tz,marginTop:e.spacing.sm},""),children:D?(0,M.Y)(l.u,{width:"100%",height:"100%",children:(0,M.FD)(d.b,{data:E,margin:{top:10,right:30,left:10,bottom:0},children:[(0,M.Y)(p.W,{dataKey:"name",...t}),(0,M.Y)(c.h,{...o}),(0,M.Y)(u.m,{content:(0,M.Y)(f.Vn,{formatter:I}),cursor:{stroke:e.colors.actionTertiaryBackgroundHover}}),(0,M.Y)(v.N,{type:"monotone",dataKey:"p50",stroke:w.p50,strokeWidth:2,dot:!1,name:"p50",strokeOpacity:C("p50")}),(0,M.Y)(v.N,{type:"monotone",dataKey:"p90",stroke:w.p90,strokeWidth:2,dot:!1,name:"p90",strokeOpacity:C("p90")}),(0,M.Y)(v.N,{type:"monotone",dataKey:"p99",stroke:w.p99,strokeWidth:2,dot:!1,name:"p99",strokeOpacity:C("p99")}),void 0!==x&&(0,M.Y)(m.e,{y:x,stroke:e.colors.textSecondary,strokeDasharray:"4 4",label:{value:`AVG (${(0,y.B4)(Math.round(x))})`,position:"insideTopRight",fill:e.colors.textSecondary,fontSize:10}}),(0,M.Y)(g.s,{verticalAlign:"bottom",iconType:"plainline",onMouseEnter:_,onMouseLeave:A,...Y})]})}):(0,M.Y)(f.iE,{})})]})}}}]);