@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
27 lines (24 loc) • 871 B
text/typescript
import { ChatModelPricing } from '@/types/aiModel';
import { ModelPriceCurrency } from '@/types/llm';
import { formatPriceByCurrency } from '@/utils/format';
export const getPrice = (pricing: ChatModelPricing) => {
const inputPrice = formatPriceByCurrency(pricing?.input, pricing?.currency as ModelPriceCurrency);
const cachedInputPrice = formatPriceByCurrency(
pricing?.cachedInput,
pricing?.currency as ModelPriceCurrency,
);
const writeCacheInputPrice = formatPriceByCurrency(
pricing?.writeCacheInput,
pricing?.currency as ModelPriceCurrency,
);
const outputPrice = formatPriceByCurrency(
pricing?.output,
pricing?.currency as ModelPriceCurrency,
);
return {
cachedInput: Number(cachedInputPrice),
input: Number(inputPrice),
output: Number(outputPrice),
writeCacheInput: Number(writeCacheInputPrice),
};
};