diff --git a/web/public/ratio.png b/web/public/ratio.png new file mode 100644 index 0000000..9c7e02c Binary files /dev/null and b/web/public/ratio.png differ diff --git a/web/src/components/ModelPricing.js b/web/src/components/ModelPricing.js index f5bb01c..57de598 100644 --- a/web/src/components/ModelPricing.js +++ b/web/src/components/ModelPricing.js @@ -1,4 +1,4 @@ -import React, { useContext, useEffect, useRef, useState } from 'react'; +import React, { useContext, useEffect, useRef, useMemo, useState } from 'react'; import { API, copy, showError, showSuccess } from '../helpers'; import { @@ -10,8 +10,16 @@ import { Table, Tag, Tooltip, + Popover, + ImagePreview, + Button, } from '@douyinfe/semi-ui'; -import { stringToColor } from '../helpers/render.js'; +import { + IconMore, + IconVerify, + IconUploadError, + IconHelpCircle, +} from '@douyinfe/semi-icons'; import { UserContext } from '../context/User/index.js'; import Text from '@douyinfe/semi-ui/lib/es/typography/text'; @@ -20,42 +28,74 @@ function renderQuotaType(type) { switch (type) { case 1: return ( - + 按次计费 ); case 0: return ( - + 按量计费 ); default: - return ( - - 未知 - - ); + return '未知'; } } function renderAvailable(available) { return available ? ( - - 可用 - + 您的分组可以使用该模型 + } + position='top' + key={available} + style={{ + backgroundColor: 'rgba(var(--semi-blue-4),1)', + borderColor: 'rgba(var(--semi-blue-4),1)', + color: 'var(--semi-color-white)', + borderWidth: 1, + borderStyle: 'solid', + }} + > + + ) : ( - - - 不可用 - - + 您的分组无权使用该模型 + } + position='top' + key={available} + style={{ + backgroundColor: 'rgba(var(--semi-blue-4),1)', + borderColor: 'rgba(var(--semi-blue-4),1)', + color: 'var(--semi-color-white)', + borderWidth: 1, + borderStyle: 'solid', + }} + > + + ); } const ModelPricing = () => { const [filteredValue, setFilteredValue] = useState([]); const compositionRef = useRef({ isComposition: false }); + const [selectedRowKeys, setSelectedRowKeys] = useState([]); + const [modalImageUrl, setModalImageUrl] = useState(''); + const [isModalOpenurl, setIsModalOpenurl] = useState(false); + + const rowSelection = useMemo( + () => ({ + onChange: (selectedRowKeys, selectedRows) => { + setSelectedRowKeys(selectedRowKeys); + }, + }), + [] + ); const handleChange = (value) => { if (compositionRef.current.isComposition) { @@ -103,7 +143,7 @@ const ModelPricing = () => { return ( <> { copyText(text); @@ -114,7 +154,8 @@ const ModelPricing = () => { ); }, - onFilter: (value, record) => record.model_name.includes(value), + onFilter: (value, record) => + record.model_name.toLowerCase().includes(value.toLowerCase()), filteredValue, }, { @@ -126,18 +167,43 @@ const ModelPricing = () => { sorter: (a, b) => a.quota_type - b.quota_type, }, { - title: '模型倍率', + title: () => ( + + 倍率 + 倍率是为了方便换算不同价格的模型
点击查看倍率说明 + } + position='top' + style={{ + backgroundColor: 'rgba(var(--semi-blue-4),1)', + borderColor: 'rgba(var(--semi-blue-4),1)', + color: 'var(--semi-color-white)', + borderWidth: 1, + borderStyle: 'solid', + }} + > + { + setModalImageUrl('/ratio.png'); + setIsModalOpenurl(true); + }} + /> +
+
+ ), dataIndex: 'model_ratio', render: (text, record, index) => { - return
{record.quota_type === 0 ? text : 'N/A'}
; - }, - }, - { - title: '补全倍率', - dataIndex: 'completion_ratio', - render: (text, record, index) => { - let ratio = parseFloat(text.toFixed(3)); - return
{record.quota_type === 0 ? ratio : 'N/A'}
; + let content = text; + let completionRatio = parseFloat(record.completion_ratio.toFixed(3)); + content = ( + <> + 模型:{record.quota_type === 0 ? text : '无'} +
+ 补全:{record.quota_type === 0 ? completionRatio : '无'} + + ); + return
{content}
; }, }, { @@ -175,7 +241,7 @@ const ModelPricing = () => { const setModelsFormat = (models, groupRatio) => { for (let i = 0; i < models.length; i++) { - models[i].key = i; + models[i].key = models[i].model_name; models[i].group_ratio = groupRatio; } // sort by quota_type @@ -238,15 +304,38 @@ const ModelPricing = () => { {userState.user ? ( ) : ( )} +
+ 按量计费费用 = 分组倍率 × 模型倍率 × (提示token数 + 补全token数 × 补全倍率)/ 500000 (单位:美元)} + closeIcon="null" + /> +
+ { pageSize: models.length, showSizeChanger: false, }} + rowSelection={rowSelection} + /> + setIsModalOpenurl(visible)} />