MCPcopy Create free account
hub / github.com/MagicCube/agentara / ContextInputUsage

Function ContextInputUsage

web/src/components/ai-elements/context.tsx:235–271  ·  view source on GitHub ↗
({
  className,
  children,
  ...props
}: ContextInputUsageProps)

Source from the content-addressed store, hash-verified

233export type ContextInputUsageProps = ComponentProps<"div">;
234
235export const ContextInputUsage = ({
236 className,
237 children,
238 ...props
239}: ContextInputUsageProps) => {
240 const { usage, modelId } = useContextValue();
241 const inputTokens = usage?.inputTokens ?? 0;
242
243 if (children) {
244 return children;
245 }
246
247 if (!inputTokens) {
248 return null;
249 }
250
251 const inputCost = modelId
252 ? getUsage({
253 modelId,
254 usage: { input: inputTokens, output: 0 },
255 }).costUSD?.totalUSD
256 : undefined;
257 const inputCostText = new Intl.NumberFormat("en-US", {
258 currency: "USD",
259 style: "currency",
260 }).format(inputCost ?? 0);
261
262 return (
263 <div
264 className={cn("flex items-center justify-between text-xs", className)}
265 {...props}
266 >
267 <span className="text-muted-foreground">Input</span>
268 <TokensWithCost costText={inputCostText} tokens={inputTokens} />
269 </div>
270 );
271};
272
273export type ContextOutputUsageProps = ComponentProps<"div">;
274

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
useContextValueFunction · 0.85

Tested by

no test coverage detected