Skip to content

Commit

Permalink
feat(pricing):add model icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Kadxy committed Sep 11, 2024
1 parent a577f0f commit fce6749
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 100 deletions.
195 changes: 107 additions & 88 deletions app/pages/Pricing.tsx
Original file line number Diff line number Diff line change
@@ -1,105 +1,124 @@
import {Row, Typography} from "antd";
import {Image, Row, Typography} from "antd";
import {SCROLL_STYLE} from "@/constant";
import {modelHub} from "ai-model-hub";
import {ProCard, ProTable} from "@ant-design/pro-components";
import {ProCard, ProTable, WaterMark} from "@ant-design/pro-components";

const {Text} = Typography;

export function PricingPage() {
return (
<div style={{...SCROLL_STYLE}}>
<Row
gutter={[16, 16]}
style={{...SCROLL_STYLE, height: "100%", padding: 32, borderRadius: 16}}
<WaterMark
content={"OpenAI-Next"}
fontColor={"rgba(0,0,0,0.1)"}
>
<>
{modelHub.getAll().map((provider) => {
return (
<ProCard
title={provider.provider}
key={provider.provider}
bordered
headerBordered
>
<ProTable
options={false}
pagination={false}
search={false}
size={"small"}
dataSource={provider.models_list}
columns={[
{
title: "模型名称",
dataIndex: "name",
width: "15%",
render: (_, record) => <Text strong copyable>{record.name}</Text>
},
{
title: "发布时间",
dataIndex: "release_time",
width: "10%",
render: (_, record) => {
try {
const timestamp = Number(record.release_time) * 1000;
if (isNaN(timestamp) || timestamp < 0) {
<Row
gutter={[16, 16]}
style={{...SCROLL_STYLE, height: "100%", padding: 32, borderRadius: 16}}
>
<>
{modelHub.getAll().map((provider) => {
return (
<ProCard
title={provider.logo.icon ? <><Image
src={provider.logo.icon?.black_white || provider.logo.icon?.color || ""}
height={32}
preview={false}
style={{verticalAlign: 'middle'}}
/>
<b style={{
fontSize: 18,
marginLeft: 8,
verticalAlign: 'middle'
}}>{provider.provider}</b></>
:
provider.provider
}
key={provider.provider}
bordered
headerBordered
>
<ProTable
options={false}
pagination={false}
search={false}
size={"small"}
dataSource={provider.models_list}
columns={[
{
title: "模型名称",
dataIndex: "name",
width: "21%",
render: (_, record) => <Text strong copyable>{record.name}</Text>
},
{
title: "发布时间",
dataIndex: "release_time",
width: "11%",
render: (_, record) => {
try {
const timestamp = Number(record.release_time) * 1000;
if (isNaN(timestamp) || timestamp < 0) {
return <Text type={"secondary"}>-</Text>
} else {
const date = {
year: new Date(timestamp).getFullYear(),
month: new Date(timestamp).getMonth() + 1,
day: new Date(timestamp).getDate(),
};
return <Text>{date.year}-{(date.month).toString().padStart(2, "0")}-{(date.day).toString().padStart(2, "0")}</Text>
}
} catch (e) {
return <Text type={"secondary"}>-</Text>
} else {
const date = {
year: new Date(timestamp).getFullYear(),
month: new Date(timestamp).getMonth() + 1,
day: new Date(timestamp).getDate(),
};
return <Text>{date.year}-{(date.month).toString().padStart(2, "0")}-{(date.day).toString().padStart(2, "0")}</Text>
}
} catch (e) {
return <Text type={"secondary"}>-</Text>
}
},
},
{
title: "模型介绍",
dataIndex: "description",
width: "38%",
ellipsis: true,
},
},
{
title: "模型介绍",
dataIndex: "description",
width: "50%",
ellipsis: true,
},
{
title: "价格(输入)",
render: (_, record) => {
const price = record?.price?.[0]?.input;
const isFree = price === 0;
return (
price ? isFree ? <Text type={"success"}>免费</Text> :
<Text>${price} / 1M tokens</Text> :
<Text type={"secondary"}>暂无</Text>
)
{
title: "价格(输入)",
render: (_, record) => {
const price = record?.price?.[0]?.input;
const isFree = price === 0;
return (
price ? isFree ? <Text type={"success"}>免费</Text> :
<Text>${price} / 1M tokens</Text> :
<Text type={"secondary"}>暂无</Text>
)
},
width: "15%",
},
width: "10%",
},
{
title: "价格(输出)",
render: (_, record) => {
const price = record?.price?.[0]?.output;
const isFree = price === 0;
return (
price ? isFree ? <Text type={"success"}>免费</Text> :
<Text>${price} / 1M tokens</Text> :
<Text type={"secondary"}>暂无</Text>
)
{
title: "价格(输出)",
render: (_, record) => {
const price = record?.price?.[0]?.output;
const isFree = price === 0;
return (
price ? isFree ? <Text type={"success"}>免费</Text> :
<Text>${price} / 1M tokens</Text> :
<Text type={"secondary"}>暂无</Text>
)
},
width: "15%",
},
width: "10%",
},
]}
/>
</ProCard>
);
})}
<Text type={"secondary"} style={{marginTop: 6}}>
You can view the update records of model information, submit feedback or suggestions in
our <Typography.Link
href={"https://github.com/OpenAI-Next/ai-model-hub"}>GitHub Repository</Typography.Link>.
</Text>
</>
</Row>
]}
scroll={{x: 950}}
/>
</ProCard>
);
})}
<Text type={"secondary"} style={{marginTop: 6}}>
You can view the update records of model information, submit feedback or suggestions in
our <Typography.Link
href={"https://github.com/OpenAI-Next/ai-model-hub"}>GitHub Repository</Typography.Link>.
</Text>
</>
</Row>
</WaterMark>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const nextConfig = {

return config;
},
transpilePackages: ['@lobehub/icons'],
// transpilePackages: [],
output: mode,
reactStrictMode: false,
images: {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
"@ant-design/nextjs-registry": "^1.0.0",
"@ant-design/pro-components": "^2.7.9",
"@fortaine/fetch-event-source": "^3.0.6",
"@lobehub/icons": "^1.22.1",
"@types/file-saver": "^2.0.7",
"ai-model-hub": "^1.1.3",
"ai-model-hub": "^1.2.1",
"ajv": "8.14.0",
"ali-oss": "^6.20.0",
"antd": "^5.17.4",
Expand Down
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1609,11 +1609,6 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@lobehub/icons@^1.22.1":
version "1.33.2"
resolved "https://registry.yarnpkg.com/@lobehub/icons/-/icons-1.33.2.tgz#bad5f0e2a30d4122b92b9b661f0db8062bdc0951"
integrity sha512-+zjI3ysaHoxZLtRW2FJtS9SYv0/hIBAllnZDuFc+PWGYOTV6E7SUFVMzjkN3XesadAXgvggLkgTM9eeZAiEPIw==

"@next/env@14.2.9":
version "14.2.9"
resolved "https://registry.yarnpkg.com/@next/env/-/env-14.2.9.tgz#f7fed48efa51b069cfc611082ad0101756df4c6a"
Expand Down Expand Up @@ -2318,10 +2313,10 @@ agentkeepalive@^3.4.1:
dependencies:
humanize-ms "^1.2.1"

ai-model-hub@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/ai-model-hub/-/ai-model-hub-1.1.3.tgz#80375e9da32899c5f0d50a768df7e7f32685951a"
integrity sha512-M40FE191n8hOpgysXbh2o9N0AexXQnEiS5P6+k5TJXGRPx4HfQNkzKhPFNpz1hI2kpPFSrH5Ciq+BzsxvelBrw==
ai-model-hub@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ai-model-hub/-/ai-model-hub-1.2.1.tgz#767fb4af124dc6435768978bcbad1d73d6af137a"
integrity sha512-pc5bvFdfJcr63opAhGxB4zDm8pMtPANojcsdtteLxM2IVPcDDO8yEXREuJXnJHdRnP/spkC7RV1wt/5lNS/I9w==

ajv-keywords@^3.5.2:
version "3.5.2"
Expand Down

0 comments on commit fce6749

Please sign in to comment.