From 38da04a7dbb1bc559c572e0db50124bd7f720fb8 Mon Sep 17 00:00:00 2001 From: Kadxy <2230318258@qq.com> Date: Tue, 10 Sep 2024 09:48:30 +0800 Subject: [PATCH] feat: update price --- app/pages/Pricing.tsx | 239 ++++++++++++++++-------------------------- 1 file changed, 90 insertions(+), 149 deletions(-) diff --git a/app/pages/Pricing.tsx b/app/pages/Pricing.tsx index f128c3b..f90c172 100644 --- a/app/pages/Pricing.tsx +++ b/app/pages/Pricing.tsx @@ -1,148 +1,9 @@ -import {Row} from "antd"; +import {Row, Typography} from "antd"; import {SCROLL_STYLE} from "@/constant"; import {modelHub} from "ai-model-hub"; +import {ProCard, ProTable} from "@ant-design/pro-components"; -// const RenderContent = (prop: { -// title: ReactNode; -// data: ProviderModelListType; -// }) => { -// const getPrice = (price: number) => { -// // 将数字转换为字符串 -// const priceString = price.toString(); -// // 找到小数点的位置 -// const decimalIndex = priceString.indexOf('.'); -// -// // 如果没有小数点,或者小数点后不足两位,则补足两位小数 -// if (decimalIndex === -1 || priceString.length - decimalIndex <= 2) { -// return price.toFixed(2); -// } else { -// // 如果有两位以上的小数,则保留原始的小数位数 -// return priceString; -// } -// } -// const renderTokenPrice = (record: ModelListType, type: "prompt" | "complete") => { -// const value = record.price[type]; -// const {Text} = Typography; -// -// if (value === null) { -// return -; -// } else { -// return ( -// <> -// ${getPrice(value)} -// / {record.price.unit || "1M tokens"} -// -// ); -// } -// } -// const renderTimesPrice = (record: ModelListType) => { -// const value = record.price.times; -// const {Text} = Typography; -// if (value === null) { -// return -; -// } -// if (typeof value === "number") { -// return ( -// <> -// ${getPrice(value)} -// / {record.price.unit || "次"} -// -// ) -// } -// if (typeof value === "object") { -// if (value.columns) return ( -// -// -// -// {value.columns.map((col: any, index: number) => ( -// -// ))} -// -// -// -// {value.dataSource.map((row: any, rowIndex: number) => ( -// -// {value.columns.map((col: any, colIndex: number) => ( -// -// ))} -// -// ))} -// -//
-// {col.title} -//
-// {col.name === "price" ? -// ${getPrice(row[col.name])} -// -// / {record.price.unit || "次"} -// -// : row[col.name]} -//
-// ); -// } -// } -// -// -// return ( -// -// {value}, -// width: "20%", -// }, -// { -// title: "类型", -// dataIndex: "category", -// width: "10%", -// }, -// { -// title: "提示价格", -// dataIndex: ["price", "prompt"], -// render: (_, record) => renderTokenPrice(record, "prompt"), -// width: "15%", -// }, -// { -// title: "补全价格", -// dataIndex: ["price", "complete"], -// render: (_, record) => renderTokenPrice(record, "complete"), -// width: "15%", -// }, -// { -// title: "按次价格", -// dataIndex: ["price", "times"], -// render: (_, record) => renderTimesPrice(record), -// width: "20%", -// }, -// { -// title: "备注", -// dataIndex: "mark", -// width: "15%", -// }, -// { -// title: "更多", -// key: "more", -// width: "5%", -// align: "center", -// render: () => 详情 -// } -// ]} -// scroll={{x: 900}} -// /> -// -// ); -// } +const {Text} = Typography; export function PricingPage() { return ( @@ -151,13 +12,93 @@ export function PricingPage() { gutter={[16, 16]} style={{...SCROLL_STYLE, height: "100%", padding: 32, borderRadius: 16}} > - {modelHub.getAll().map((provider) => { - return ( - <> - {provider.models_list} - - ); - })} + <> + {modelHub.getAll().map((provider) => { + return ( + + {record.name} + }, + { + title: "发布时间", + dataIndex: "release_time", + width: "10%", + render: (_, record) => { + try { + const timestamp = Number(record.release_time) * 1000; + if (isNaN(timestamp) || timestamp < 0) { + return - + } else { + const date = { + year: new Date(timestamp).getFullYear(), + month: new Date(timestamp).getMonth() + 1, + day: new Date(timestamp).getDate(), + }; + return {date.year}-{(date.month).toString().padStart(2, "0")}-{(date.day).toString().padStart(2, "0")} + } + } catch (e) { + return - + } + }, + }, + { + title: "模型介绍", + dataIndex: "description", + width: "50%", + ellipsis: true, + }, + { + title: "价格(输入)", + render: (_, record) => { + const price = record?.price?.[0]?.input; + const isFree = price === 0; + return ( + price ? isFree ? 免费 : + ${price} / 1M tokens : + 暂无 + ) + }, + width: "10%", + }, + { + title: "价格(输出)", + render: (_, record) => { + const price = record?.price?.[0]?.output; + const isFree = price === 0; + return ( + price ? isFree ? 免费 : + ${price} / 1M tokens : + 暂无 + ) + }, + width: "10%", + }, + ]} + /> + + ); + })} + + You can view the update records of model information, submit feedback or suggestions in + our GitHub Repository. + + );