capsule-ai-cli
Version:
The AI Model Orchestrator - Intelligent multi-model workflows with device-locked licensing
46 lines • 2.09 kB
JavaScript
import React from 'react';
import { Box, Text } from 'ink';
import chalk from 'chalk';
import { getProviderColor } from '../utils/provider-colors.js';
import { getModelDisplayName } from '../utils/model-display.js';
import { openRouterModelsService } from '../../services/openrouter-models.js';
export const ModelItem = ({ isSelected = false, value, provider, isCurrent }) => {
const providerColor = getProviderColor(provider);
const model = openRouterModelsService.getModel(value);
const displayName = getModelDisplayName(value);
const formatPrice = (price) => {
const numPrice = typeof price === 'string' ? parseFloat(price) : price;
if (numPrice === 0)
return 'Free';
const perMillion = numPrice * 1000000;
if (perMillion < 1) {
return `$${perMillion.toFixed(2)}/1M`;
}
return `$${perMillion.toFixed(0)}/1M`;
};
const formatContext = (context) => {
if (context >= 1000000)
return `${(context / 1000000).toFixed(1)}M`;
if (context >= 1000)
return `${Math.round(context / 1000)}K`;
return context.toString();
};
const pricing = model ? {
prompt: formatPrice(model.pricing.prompt),
completion: formatPrice(model.pricing.completion)
} : null;
const contextWindow = model ? formatContext(model.context_length) : '?';
return (React.createElement(Box, null,
React.createElement(Box, { width: 35, flexShrink: 0 },
React.createElement(Text, { color: isSelected ? providerColor : undefined, wrap: "truncate" },
displayName,
isCurrent && chalk.green(' (current)'))),
React.createElement(Box, { width: 8, flexShrink: 0 },
React.createElement(Text, { dimColor: true }, contextWindow)),
pricing && (React.createElement(Box, { flexGrow: 1 },
React.createElement(Text, { dimColor: true },
pricing.prompt,
" \u2192 ",
pricing.completion)))));
};
//# sourceMappingURL=ModelItem.js.map