({
totalBytes,
llmCalls,
totalContextBytes,
averageContextBytes,
totalTimeMs,
model,
}: NoCodeMetricsProps)
| 202 | } |
| 203 | |
| 204 | export function NoCodeMetrics({ |
| 205 | totalBytes, |
| 206 | llmCalls, |
| 207 | totalContextBytes, |
| 208 | averageContextBytes, |
| 209 | totalTimeMs, |
| 210 | model, |
| 211 | }: NoCodeMetricsProps) { |
| 212 | const [isOpen, setIsOpen] = useState(false) |
| 213 | const estimatedTimeMs = estimateRoundTripTimeMs(llmCalls) |
| 214 | const resolvedTimeMs = totalTimeMs ?? estimatedTimeMs |
| 215 | const estimatedCost = estimateCostFromBytes(totalBytes, model) |
| 216 | |
| 217 | if (totalBytes <= 0 || llmCalls <= 0) return null |
| 218 | |
| 219 | return ( |
| 220 | <div className="relative"> |
| 221 | <button |
| 222 | onClick={() => setIsOpen(!isOpen)} |
| 223 | className="flex items-center gap-2 px-2.5 py-1.5 rounded-lg hover:bg-gray-700/50 transition-colors" |
| 224 | title="Chat Metrics" |
| 225 | > |
| 226 | <Info className="w-3.5 h-3.5 text-cyan-500" /> |
| 227 | <span className="text-xs text-gray-400 font-medium">Chat metrics</span> |
| 228 | </button> |
| 229 | |
| 230 | {isOpen && ( |
| 231 | <> |
| 232 | <div |
| 233 | className="fixed inset-0 z-40" |
| 234 | onClick={() => setIsOpen(false)} |
| 235 | /> |
| 236 | |
| 237 | <div className="absolute right-0 top-full mt-2 w-80 bg-gray-900 border border-gray-700 rounded-xl shadow-xl z-50 overflow-hidden"> |
| 238 | <div className="px-4 py-3 border-b border-gray-700/50"> |
| 239 | <h3 className="font-medium text-gray-200">Chat Metrics</h3> |
| 240 | </div> |
| 241 | |
| 242 | <div className="p-4 space-y-4"> |
| 243 | <ValueRow |
| 244 | label="Message Size" |
| 245 | value={formatBytes(totalBytes)} |
| 246 | description="Final serialized size of the messages array." |
| 247 | /> |
| 248 | {typeof totalContextBytes === 'number' && |
| 249 | totalContextBytes > 0 && ( |
| 250 | <ValueRow |
| 251 | label="Context Bytes (Total)" |
| 252 | value={formatBytes(totalContextBytes)} |
| 253 | description="Accumulated context size across LLM calls." |
| 254 | /> |
| 255 | )} |
| 256 | {typeof averageContextBytes === 'number' && |
| 257 | averageContextBytes > 0 && ( |
| 258 | <ValueRow |
| 259 | label="Context Bytes (Avg)" |
| 260 | value={formatBytes(averageContextBytes)} |
| 261 | description="Average context size per LLM call." |
nothing calls this directly
no test coverage detected