Adaptive Batch Card
Surfaces useAdaptiveBatchSize: a computed optimal batch number, hardware summary, detection source, and collapsible reasoning — with a compact badge variant.
Adaptive Batch Card
The Adaptive Batch Card surfaces useAdaptiveBatchSize output: a prominent computed optimal batch number, a hardware summary (cores / RAM / GPU), the detection source (detected / estimated / override), and a collapsible reasoning string. A compact AdaptiveBatchBadge variant (e.g. "Batch: 32") offers a click-to-expand device-profile popover. Use it to explain why your embedMany / ingest batch size is what it is on this device.
Preview
Installation
pnpm dlx shadcn@latest add @localmode/ui/local-first/adaptive-batch-cardnpx shadcn@latest add @localmode/ui/local-first/adaptive-batch-cardyarn dlx shadcn@latest add @localmode/ui/local-first/adaptive-batch-cardbunx --bun shadcn@latest add @localmode/ui/local-first/adaptive-batch-cardData source & dependencies
Data source: renders the batch-size result you pass — works with any backend. Recommended producer: useAdaptiveBatchSize (backed by computeOptimalBatchSize) from @localmode/react (on-device, optional).
lucide-react— iconsclsx+tailwind-merge— via the sharedcn()util (installed automatically as a registry dependency)
Files installed
adaptive-batch-card.tsx—AdaptiveBatchCard+AdaptiveBatchBadgelib/utils.ts— thecn()helper (if not already present)
Props
AdaptiveBatchCard
Prop
Type
AdaptiveBatchResult
Prop
Type
Examples
Bound to the hook
const result = useAdaptiveBatchSize({ taskType: 'embedding', modelDimensions: 384 });
<AdaptiveBatchCard result={result} />
<AdaptiveBatchBadge result={result} />Customization
The result shape is exactly useAdaptiveBatchSize's return ({ batchSize, reasoning, deviceProfile }), so you can pass it straight through. The badge popover summarizes the device profile. Styled entirely with shadcn/ui CSS-variable utilities so it inherits your theme — because you own the copied file, every class and threshold is yours to change.