Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Modal, Typography, Button, Spin } from '@douyinfe/semi-ui';
|
||||
import { X, Bot } from 'lucide-react';
|
||||
|
||||
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
||||
import ModelHeader from './components/ModelHeader';
|
||||
import ModelBasicInfo from './components/ModelBasicInfo';
|
||||
import ModelEndpoints from './components/ModelEndpoints';
|
||||
import ModelPricingTable from './components/ModelPricingTable';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const ModelDetailSideSheet = ({
|
||||
visible,
|
||||
onClose,
|
||||
modelData,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
currency,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
showRatio,
|
||||
hidePrice,
|
||||
usableGroup,
|
||||
vendorsMap,
|
||||
endpointMap,
|
||||
autoGroups,
|
||||
t,
|
||||
}) => {
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={null}
|
||||
header={null}
|
||||
footer={null}
|
||||
bodyStyle={{
|
||||
padding: '0',
|
||||
borderRadius: '20px',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
className='model-detail-modal'
|
||||
visible={visible}
|
||||
width={isMobile ? '95%' : 560}
|
||||
centered
|
||||
closeIcon={null}
|
||||
onCancel={onClose}
|
||||
maskClosable={true}
|
||||
maskStyle={{
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.4)',
|
||||
backdropFilter: 'blur(8px)',
|
||||
}}
|
||||
>
|
||||
{/* 自定义头部 */}
|
||||
<div className='px-4 pt-4 pb-3'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='p-1.5 bg-gradient-to-br from-brand-from to-brand-to rounded-lg'>
|
||||
<Bot size={16} className='text-white' />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className='text-sm font-semibold text-gray-800 dark:text-gray-100'>
|
||||
{t('模型详情')}
|
||||
</h2>
|
||||
<p className='text-[11px] text-gray-500 dark:text-gray-400'>
|
||||
{t('查看模型定价与配置信息')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 关闭按钮 */}
|
||||
<button
|
||||
onClick={onClose}
|
||||
className='p-1.5 rounded-lg bg-gray-100 hover:bg-gray-200 dark:bg-neutral-800 dark:hover:bg-neutral-700 transition-colors'
|
||||
>
|
||||
<X size={16} className='text-gray-500 dark:text-gray-400' />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 模型标题 */}
|
||||
{modelData && (
|
||||
<div className='mt-2'>
|
||||
<ModelHeader modelData={modelData} vendorsMap={vendorsMap} t={t} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 内容区域 */}
|
||||
<div
|
||||
className='overflow-y-auto'
|
||||
style={{
|
||||
maxHeight: isMobile ? 'calc(85vh - 180px)' : 'calc(75vh - 160px)',
|
||||
}}
|
||||
>
|
||||
<div className='px-4 pb-3'>
|
||||
{!modelData ? (
|
||||
<div className='flex flex-col justify-center items-center py-12'>
|
||||
<Spin size='large' />
|
||||
<Text type='secondary' className='mt-3'>
|
||||
{t('加载中...')}
|
||||
</Text>
|
||||
</div>
|
||||
) : (
|
||||
/* 分区平铺 + 发丝分隔线:原先每区一层白卡边框,与弹窗自身、
|
||||
* 区内表格边框叠出三层线框(用户反馈嵌套过多),改为零嵌套 */
|
||||
<div className='divide-y divide-gray-100 dark:divide-neutral-800'>
|
||||
{/* 基本信息 */}
|
||||
<div className='py-3 first:pt-1'>
|
||||
<ModelBasicInfo
|
||||
modelData={modelData}
|
||||
vendorsMap={vendorsMap}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 端点信息 */}
|
||||
<div className='py-3'>
|
||||
<ModelEndpoints
|
||||
modelData={modelData}
|
||||
endpointMap={endpointMap}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 定价表格 */}
|
||||
{!hidePrice && (
|
||||
<div className='py-3'>
|
||||
<ModelPricingTable
|
||||
modelData={modelData}
|
||||
groupRatio={groupRatio}
|
||||
groupModelDiscount={groupModelDiscount}
|
||||
currency={currency}
|
||||
tokenUnit={tokenUnit}
|
||||
displayPrice={displayPrice}
|
||||
showRatio={showRatio}
|
||||
usableGroup={usableGroup}
|
||||
autoGroups={autoGroups}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 底部按钮 */}
|
||||
<div className='px-4 pb-4 pt-2'>
|
||||
<Button
|
||||
block
|
||||
theme='solid'
|
||||
onClick={onClose}
|
||||
className='!bg-gradient-to-r !from-brand-from !to-brand-to hover:!from-brand-from hover:!to-brand-to !rounded-xl !h-10 !font-medium !shadow-md !shadow-brand/20 transition-all'
|
||||
>
|
||||
{t('关闭')}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelDetailSideSheet;
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Modal } from '@douyinfe/semi-ui';
|
||||
import { resetPricingFilters } from '../../../../helpers/utils';
|
||||
import FilterModalContent from './components/FilterModalContent';
|
||||
import FilterModalFooter from './components/FilterModalFooter';
|
||||
|
||||
const PricingFilterModal = ({ visible, onClose, sidebarProps, t }) => {
|
||||
const handleResetFilters = () =>
|
||||
resetPricingFilters({
|
||||
handleChange: sidebarProps.handleChange,
|
||||
setShowWithRecharge: sidebarProps.setShowWithRecharge,
|
||||
setCurrency: sidebarProps.setCurrency,
|
||||
setViewMode: sidebarProps.setViewMode,
|
||||
setFilterGroup: sidebarProps.setFilterGroup,
|
||||
setFilterQuotaType: sidebarProps.setFilterQuotaType,
|
||||
setFilterEndpointType: sidebarProps.setFilterEndpointType,
|
||||
setFilterVendor: sidebarProps.setFilterVendor,
|
||||
setFilterTag: sidebarProps.setFilterTag,
|
||||
setCurrentPage: sidebarProps.setCurrentPage,
|
||||
setTokenUnit: sidebarProps.setTokenUnit,
|
||||
});
|
||||
|
||||
const footer = (
|
||||
<FilterModalFooter onReset={handleResetFilters} onConfirm={onClose} t={t} />
|
||||
);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('筛选')}
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
footer={footer}
|
||||
className='pricing-filter-modal'
|
||||
style={{ width: '100%', height: '100%', margin: 0 }}
|
||||
bodyStyle={{
|
||||
padding: 0,
|
||||
height: 'calc(100vh - 160px)',
|
||||
overflowY: 'auto',
|
||||
scrollbarWidth: 'none',
|
||||
msOverflowStyle: 'none',
|
||||
backgroundColor: 'var(--semi-color-bg-0)',
|
||||
}}
|
||||
>
|
||||
<FilterModalContent sidebarProps={sidebarProps} t={t} />
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingFilterModal;
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PricingDisplaySettings from '../../filter/PricingDisplaySettings';
|
||||
import PricingGroups from '../../filter/PricingGroups';
|
||||
import PricingQuotaTypes from '../../filter/PricingQuotaTypes';
|
||||
import PricingEndpointTypes from '../../filter/PricingEndpointTypes';
|
||||
import PricingVendors from '../../filter/PricingVendors';
|
||||
import PricingTags from '../../filter/PricingTags';
|
||||
import { usePricingFilterCounts } from '../../../../../hooks/model-pricing/usePricingFilterCounts';
|
||||
|
||||
const FilterModalContent = ({ sidebarProps, t }) => {
|
||||
const {
|
||||
showWithRecharge,
|
||||
setShowWithRecharge,
|
||||
currency,
|
||||
setCurrency,
|
||||
handleChange,
|
||||
setActiveKey,
|
||||
showRatio,
|
||||
viewMode,
|
||||
setViewMode,
|
||||
filterGroup,
|
||||
setFilterGroup,
|
||||
filterQuotaType,
|
||||
setFilterQuotaType,
|
||||
filterEndpointType,
|
||||
setFilterEndpointType,
|
||||
filterVendor,
|
||||
setFilterVendor,
|
||||
filterTag,
|
||||
setFilterTag,
|
||||
tokenUnit,
|
||||
setTokenUnit,
|
||||
loading,
|
||||
...categoryProps
|
||||
} = sidebarProps;
|
||||
|
||||
const {
|
||||
quotaTypeModels,
|
||||
endpointTypeModels,
|
||||
vendorModels,
|
||||
tagModels,
|
||||
groupCountModels,
|
||||
} = usePricingFilterCounts({
|
||||
models: categoryProps.models,
|
||||
filterGroup,
|
||||
filterQuotaType,
|
||||
filterEndpointType,
|
||||
filterVendor,
|
||||
filterTag,
|
||||
searchValue: sidebarProps.searchValue,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<PricingDisplaySettings
|
||||
showWithRecharge={showWithRecharge}
|
||||
setShowWithRecharge={setShowWithRecharge}
|
||||
currency={currency}
|
||||
setCurrency={setCurrency}
|
||||
showRatio={showRatio}
|
||||
viewMode={viewMode}
|
||||
setViewMode={setViewMode}
|
||||
tokenUnit={tokenUnit}
|
||||
setTokenUnit={setTokenUnit}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<PricingVendors
|
||||
filterVendor={filterVendor}
|
||||
setFilterVendor={setFilterVendor}
|
||||
models={vendorModels}
|
||||
allModels={categoryProps.models}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<PricingTags
|
||||
filterTag={filterTag}
|
||||
setFilterTag={setFilterTag}
|
||||
models={tagModels}
|
||||
allModels={categoryProps.models}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<PricingGroups
|
||||
filterGroup={filterGroup}
|
||||
setFilterGroup={setFilterGroup}
|
||||
usableGroup={categoryProps.usableGroup}
|
||||
groupRatio={categoryProps.groupRatio}
|
||||
models={groupCountModels}
|
||||
loading={loading}
|
||||
showRatio={showRatio}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<PricingQuotaTypes
|
||||
filterQuotaType={filterQuotaType}
|
||||
setFilterQuotaType={setFilterQuotaType}
|
||||
models={quotaTypeModels}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<PricingEndpointTypes
|
||||
filterEndpointType={filterEndpointType}
|
||||
setFilterEndpointType={setFilterEndpointType}
|
||||
models={endpointTypeModels}
|
||||
allModels={categoryProps.models}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default FilterModalContent;
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Button } from '@douyinfe/semi-ui';
|
||||
|
||||
const FilterModalFooter = ({ onReset, onConfirm, t }) => {
|
||||
return (
|
||||
<div className='flex justify-end'>
|
||||
<Button theme='outline' type='tertiary' onClick={onReset}>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
<Button theme='solid' type='primary' onClick={onConfirm}>
|
||||
{t('确定')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FilterModalFooter;
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { FileText, Sparkles } from 'lucide-react';
|
||||
import { stringToColor } from '../../../../../helpers';
|
||||
|
||||
const ModelBasicInfo = ({ modelData, vendorsMap = {}, t }) => {
|
||||
// 获取模型描述
|
||||
const getModelDescription = () => {
|
||||
if (!modelData) return t('暂无模型描述');
|
||||
if (modelData.description) return modelData.description;
|
||||
if (modelData.vendor_description)
|
||||
return t('供应商信息:') + modelData.vendor_description;
|
||||
return t('暂无模型描述');
|
||||
};
|
||||
|
||||
// 获取模型标签
|
||||
const getModelTags = () => {
|
||||
const tags = [];
|
||||
if (modelData?.tags) {
|
||||
const customTags = modelData.tags.split(',').filter((tag) => tag.trim());
|
||||
customTags.forEach((tag) => {
|
||||
const tagText = tag.trim();
|
||||
tags.push({ text: tagText, color: stringToColor(tagText) });
|
||||
});
|
||||
}
|
||||
return tags;
|
||||
};
|
||||
|
||||
const tags = getModelTags();
|
||||
|
||||
return (
|
||||
<div className='space-y-3'>
|
||||
{/* 标题行 —— 单行紧凑小节头(原大色块 chip+副标题在弹窗内层级过重) */}
|
||||
<h3 className='flex items-center gap-1.5 text-[13px] font-semibold text-gray-900 dark:text-white'>
|
||||
<FileText
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from flex-shrink-0'
|
||||
/>
|
||||
{t('基本信息')}
|
||||
</h3>
|
||||
|
||||
{/* 描述区域 */}
|
||||
<div className='relative pl-3'>
|
||||
<div className='absolute left-0 top-0 bottom-0 w-0.5 rounded-full bg-brand-from' />
|
||||
<p className='text-sm text-gray-600 dark:text-gray-300 leading-relaxed'>
|
||||
{getModelDescription()}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 标签区域 */}
|
||||
{tags.length > 0 && (
|
||||
<div className='flex flex-wrap gap-1.5'>
|
||||
{tags.map((tag, index) => (
|
||||
<span
|
||||
key={index}
|
||||
className='inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium'
|
||||
style={{
|
||||
backgroundColor: `${tag.color}15`,
|
||||
color: tag.color,
|
||||
}}
|
||||
>
|
||||
<Sparkles size={10} />
|
||||
{tag.text}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelBasicInfo;
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Plug, Zap, ArrowRight, Globe } from 'lucide-react';
|
||||
|
||||
const ModelEndpoints = ({ modelData, endpointMap = {}, t }) => {
|
||||
const types = modelData?.supported_endpoint_types || [];
|
||||
|
||||
const getEndpointInfo = (type) => {
|
||||
const info = endpointMap[type] || {};
|
||||
let path = info.path || '';
|
||||
if (path.includes('{model}')) {
|
||||
const modelName = modelData?.model_name || modelData?.modelName || '';
|
||||
path = path.replaceAll('{model}', modelName);
|
||||
}
|
||||
return { path, method: info.method || 'POST' };
|
||||
};
|
||||
|
||||
const getMethodColor = (method) => {
|
||||
const colors = {
|
||||
GET: {
|
||||
bg: 'bg-emerald-500/10',
|
||||
text: 'text-emerald-600 dark:text-emerald-400',
|
||||
border: 'border-emerald-500/20',
|
||||
},
|
||||
POST: {
|
||||
bg: 'bg-blue-500/10',
|
||||
text: 'text-blue-600 dark:text-blue-400',
|
||||
border: 'border-blue-500/20',
|
||||
},
|
||||
PUT: {
|
||||
bg: 'bg-amber-500/10',
|
||||
text: 'text-amber-600 dark:text-amber-400',
|
||||
border: 'border-amber-500/20',
|
||||
},
|
||||
DELETE: {
|
||||
bg: 'bg-red-500/10',
|
||||
text: 'text-red-600 dark:text-red-400',
|
||||
border: 'border-red-500/20',
|
||||
},
|
||||
};
|
||||
return colors[method] || colors.POST;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='space-y-3'>
|
||||
{/* 标题区域 —— 单行紧凑小节头 */}
|
||||
<div className='flex items-center justify-between'>
|
||||
<h3 className='flex items-center gap-1.5 text-[13px] font-semibold text-gray-900 dark:text-white'>
|
||||
<Plug
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from flex-shrink-0'
|
||||
/>
|
||||
{t('API端点')}
|
||||
</h3>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 font-medium'>
|
||||
<Globe size={12} className='inline mr-1' />
|
||||
{types.length} {t('个端点')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* 端点列表 */}
|
||||
<div className='space-y-2'>
|
||||
{types.map((type) => {
|
||||
const { path, method } = getEndpointInfo(type);
|
||||
const methodStyle = getMethodColor(method);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={type}
|
||||
className='flex items-center justify-between gap-3 py-2'
|
||||
>
|
||||
<div className='flex-1 min-w-0'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Zap size={12} className='text-brand flex-shrink-0' />
|
||||
<span className='text-sm font-medium text-gray-900 dark:text-white'>
|
||||
{type}
|
||||
</span>
|
||||
</div>
|
||||
{path && (
|
||||
<div className='flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mt-0.5 ml-5'>
|
||||
<ArrowRight size={10} className='flex-shrink-0' />
|
||||
<code className='font-mono text-gray-600 dark:text-gray-300'>
|
||||
{path}
|
||||
</code>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{path && (
|
||||
<span
|
||||
className={`flex-shrink-0 px-2 py-0.5 rounded text-xs font-semibold ${methodStyle.bg} ${methodStyle.text}`}
|
||||
>
|
||||
{method}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{types.length === 0 && (
|
||||
<div className='text-center py-6 text-gray-400 dark:text-gray-500'>
|
||||
<Plug size={24} className='mx-auto mb-2 opacity-50' />
|
||||
<p className='text-sm'>{t('暂无端点信息')}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelEndpoints;
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Typography, Toast, Avatar } from '@douyinfe/semi-ui';
|
||||
import { getLobeHubIcon } from '../../../../../helpers';
|
||||
|
||||
const { Paragraph } = Typography;
|
||||
|
||||
const CARD_STYLES = {
|
||||
container:
|
||||
'w-12 h-12 rounded-2xl flex items-center justify-center relative shadow-md',
|
||||
icon: 'w-8 h-8 flex items-center justify-center',
|
||||
};
|
||||
|
||||
const ModelHeader = ({ modelData, vendorsMap = {}, t }) => {
|
||||
// 获取模型图标(优先模型图标,其次供应商图标)
|
||||
const getModelIcon = () => {
|
||||
// 1) 优先使用模型自定义图标
|
||||
if (modelData?.icon) {
|
||||
return (
|
||||
<div className={CARD_STYLES.container}>
|
||||
<div className={CARD_STYLES.icon}>
|
||||
{getLobeHubIcon(modelData.icon, 32)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// 2) 退化为供应商图标
|
||||
if (modelData?.vendor_icon) {
|
||||
return (
|
||||
<div className={CARD_STYLES.container}>
|
||||
<div className={CARD_STYLES.icon}>
|
||||
{getLobeHubIcon(modelData.vendor_icon, 32)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 如果没有供应商图标,使用模型名称的前两个字符
|
||||
const avatarText = modelData?.model_name?.slice(0, 2).toUpperCase() || 'AI';
|
||||
return (
|
||||
<div className={CARD_STYLES.container}>
|
||||
<Avatar
|
||||
size='large'
|
||||
style={{
|
||||
width: 48,
|
||||
height: 48,
|
||||
borderRadius: 16,
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
}}
|
||||
>
|
||||
{avatarText}
|
||||
</Avatar>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='flex items-center'>
|
||||
{getModelIcon()}
|
||||
<div className='ml-3 font-normal'>
|
||||
<Paragraph
|
||||
className='!mb-0 !text-lg !font-medium'
|
||||
copyable={{
|
||||
content: modelData?.model_name || '',
|
||||
onCopy: () => Toast.success({ content: t('已复制模型名称') }),
|
||||
}}
|
||||
>
|
||||
<span className='truncate max-w-60 font-bold'>
|
||||
{modelData?.model_name || t('未知模型')}
|
||||
</span>
|
||||
</Paragraph>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelHeader;
|
||||
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Coins,
|
||||
ChevronRight,
|
||||
Layers,
|
||||
Calculator,
|
||||
BadgePercent,
|
||||
} from 'lucide-react';
|
||||
import {
|
||||
calculateModelPrice,
|
||||
formatOfficialPriceDisplay,
|
||||
getDiscountBadgeText,
|
||||
} from '../../../../../helpers';
|
||||
|
||||
const ModelPricingTable = ({
|
||||
modelData,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
currency,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
showRatio,
|
||||
usableGroup,
|
||||
autoGroups = [],
|
||||
t,
|
||||
}) => {
|
||||
const modelEnableGroups = Array.isArray(modelData?.enable_groups)
|
||||
? modelData.enable_groups
|
||||
: [];
|
||||
const autoChain = autoGroups.filter((g) => modelEnableGroups.includes(g));
|
||||
|
||||
const availableGroups = Object.keys(usableGroup || {})
|
||||
.filter((g) => g !== '' && g !== 'auto')
|
||||
.filter((g) => modelEnableGroups.includes(g));
|
||||
|
||||
const getPriceData = (group) => {
|
||||
return modelData
|
||||
? calculateModelPrice({
|
||||
record: modelData,
|
||||
selectedGroup: group,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
currency,
|
||||
})
|
||||
: { inputPrice: '-', outputPrice: '-', price: '-' };
|
||||
};
|
||||
|
||||
const isPerToken = modelData?.quota_type === 0;
|
||||
const isPerSecond = modelData?.quota_type === 2;
|
||||
const isPerImageResolution = modelData?.quota_type === 3;
|
||||
|
||||
// 官方价参考行:仅当至少一个可用分组的实付价低于官方牌价时展示
|
||||
//(与卡片折扣徽标同一保守口径,避免展示「站内比官方还贵」的对照)
|
||||
const groupPriceDataList = availableGroups.map((g) => getPriceData(g));
|
||||
const hasAnyDiscount = groupPriceDataList.some((pd) => pd?.discountBadge);
|
||||
const officialDisplay =
|
||||
hasAnyDiscount && modelData?.official_price
|
||||
? formatOfficialPriceDisplay({
|
||||
official: modelData.official_price,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
})
|
||||
: null;
|
||||
const billingLabel = isPerSecond
|
||||
? t('按秒计费')
|
||||
: isPerImageResolution
|
||||
? t('按分辨率计费')
|
||||
: isPerToken
|
||||
? t('按量计费')
|
||||
: t('按次计费');
|
||||
const tokenLabel = tokenUnit === 'K' ? '1K' : '1M';
|
||||
const samplePriceData = isPerToken
|
||||
? getPriceData(availableGroups[0] || 'all')
|
||||
: null;
|
||||
const extraPriceColumns = Array.isArray(samplePriceData?.extraPrices)
|
||||
? samplePriceData.extraPrices
|
||||
: [];
|
||||
// 按秒分档:列 = 各档位,由配置顺序决定
|
||||
const videoTierColumns = isPerSecond
|
||||
? (modelData?.video_second_pricing?.tiers || []).map((tier) => ({
|
||||
key: tier.key,
|
||||
label: tier.label || tier.key,
|
||||
}))
|
||||
: [];
|
||||
const imageTierColumns = isPerImageResolution
|
||||
? (modelData?.image_resolution_pricing?.tiers || []).map((tier) => ({
|
||||
key: tier.key,
|
||||
label: tier.label || tier.key,
|
||||
}))
|
||||
: [];
|
||||
const tierColumns = isPerSecond ? videoTierColumns : imageTierColumns;
|
||||
const isTierPricing = isPerSecond || isPerImageResolution;
|
||||
const priceGridStyle = isTierPricing
|
||||
? {
|
||||
gridTemplateColumns: `minmax(76px, 1fr) repeat(${Math.max(tierColumns.length, 1)}, minmax(88px, max-content))`,
|
||||
minWidth:
|
||||
tierColumns.length > 0
|
||||
? `${160 + tierColumns.length * 100}px`
|
||||
: undefined,
|
||||
}
|
||||
: isPerToken
|
||||
? {
|
||||
gridTemplateColumns: `minmax(76px, 1fr) repeat(${2 + extraPriceColumns.length}, minmax(88px, max-content))`,
|
||||
minWidth:
|
||||
extraPriceColumns.length > 0
|
||||
? `${260 + extraPriceColumns.length * 108}px`
|
||||
: undefined,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<div className='space-y-3'>
|
||||
{/* 标题区域 —— 单行紧凑小节头 */}
|
||||
<div className='flex items-center justify-between'>
|
||||
<h3 className='flex items-center gap-1.5 text-[13px] font-semibold text-gray-900 dark:text-white'>
|
||||
<Coins
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from flex-shrink-0'
|
||||
/>
|
||||
{t('分组价格')}
|
||||
</h3>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 font-medium'>
|
||||
<Calculator size={12} className='inline mr-1' />
|
||||
{billingLabel}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Auto分组链路 */}
|
||||
{autoChain.length > 0 && (
|
||||
<div className='flex items-center flex-wrap gap-1.5 text-xs text-gray-500 dark:text-gray-400'>
|
||||
<Layers size={12} className='text-brand' />
|
||||
<span>{t('auto分组调用链路')}</span>
|
||||
{autoChain.map((g, idx) => (
|
||||
<React.Fragment key={g}>
|
||||
<span className='px-1.5 py-0.5 rounded text-brand-deep dark:text-brand-from font-medium bg-brand/10'>
|
||||
{g}
|
||||
</span>
|
||||
{idx < autoChain.length - 1 && (
|
||||
<ChevronRight size={10} className='text-gray-400' />
|
||||
)}
|
||||
</React.Fragment>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 价格表格 */}
|
||||
<div className='overflow-x-auto'>
|
||||
{/* 表头 */}
|
||||
<div
|
||||
className={`grid ${isPerToken || isTierPricing ? '' : 'grid-cols-2'} text-[11px] font-medium text-gray-400 dark:text-gray-400 border-b border-gray-100 dark:border-neutral-700 pb-2 mb-1`}
|
||||
style={priceGridStyle}
|
||||
>
|
||||
<div>{t('分组')}</div>
|
||||
{isPerSecond ? (
|
||||
videoTierColumns.map((col) => (
|
||||
<div key={col.key} className='text-right'>
|
||||
{col.label} / {t('秒')}
|
||||
</div>
|
||||
))
|
||||
) : isPerImageResolution ? (
|
||||
imageTierColumns.map((col) => (
|
||||
<div key={col.key} className='text-right'>
|
||||
{col.label} / {t('张')}
|
||||
</div>
|
||||
))
|
||||
) : isPerToken ? (
|
||||
<>
|
||||
<div className='text-right'>
|
||||
{t('输入价格')} / {tokenLabel}
|
||||
</div>
|
||||
<div className='text-right'>
|
||||
{t('输出价格')} / {tokenLabel}
|
||||
</div>
|
||||
{extraPriceColumns.map((item) => (
|
||||
<div key={item.key} className='text-right'>
|
||||
{t(item.labelKey)} / {tokenLabel}
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
) : (
|
||||
<div className='text-right'>
|
||||
{t('单价')} / {t('次')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 官方价参考行:管理员维护的原厂牌价(不含分组倍率),供各分组折扣对照 */}
|
||||
{officialDisplay && !isTierPricing && (
|
||||
<div
|
||||
className={`grid ${isPerToken ? '' : 'grid-cols-2'} items-center py-1.5 rounded-lg bg-gray-50/80 dark:bg-neutral-800/60`}
|
||||
style={priceGridStyle}
|
||||
>
|
||||
<div className='flex items-center gap-1.5 pl-1'>
|
||||
<BadgePercent size={12} className='text-gray-400' />
|
||||
<span
|
||||
className='text-sm text-gray-500 dark:text-gray-400'
|
||||
title={t('管理员维护的模型原厂牌价,未含分组倍率,仅供对照')}
|
||||
>
|
||||
{t('官方价')}
|
||||
</span>
|
||||
</div>
|
||||
{isPerToken ? (
|
||||
<>
|
||||
<div className='text-right'>
|
||||
<span className='text-sm text-gray-500 dark:text-gray-400 line-through'>
|
||||
{officialDisplay.input || '-'}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-right'>
|
||||
<span className='text-sm text-gray-500 dark:text-gray-400 line-through'>
|
||||
{officialDisplay.output || '-'}
|
||||
</span>
|
||||
</div>
|
||||
{extraPriceColumns.map((column) => (
|
||||
<div key={column.key} className='text-right'>
|
||||
<span className='text-sm text-gray-400'>-</span>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
) : (
|
||||
<div className='text-right'>
|
||||
<span className='text-sm text-gray-500 dark:text-gray-400 line-through'>
|
||||
{officialDisplay.perCall || '-'}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 数据行 */}
|
||||
<div className='space-y-0.5'>
|
||||
{availableGroups.map((group, idx) => {
|
||||
const priceData = groupPriceDataList[idx];
|
||||
const discountText = getDiscountBadgeText(priceData);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={group}
|
||||
className={`grid ${isPerToken || isTierPricing ? '' : 'grid-cols-2'} items-center py-1.5`}
|
||||
style={priceGridStyle}
|
||||
>
|
||||
<div className='flex items-center gap-1.5'>
|
||||
<span
|
||||
className={`w-1.5 h-1.5 rounded-full ${idx % 3 === 0 ? 'bg-emerald-500' : idx % 3 === 1 ? 'bg-blue-500' : 'bg-brand'}`}
|
||||
/>
|
||||
<span className='text-sm text-gray-700 dark:text-gray-200'>
|
||||
{group}
|
||||
</span>
|
||||
{discountText && (
|
||||
<span
|
||||
className='px-1.5 py-[1px] rounded-full text-[10px] font-semibold leading-4
|
||||
text-brand-deep dark:text-brand-from bg-brand/10 dark:bg-brand-deep/30
|
||||
border border-brand/25 dark:border-brand-deep/50 select-none'
|
||||
title={t(
|
||||
'相比官方牌价的折扣,按当前计价分组实付价计算(已含您的等级折扣),仅供参考',
|
||||
)}
|
||||
>
|
||||
{discountText}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{isPerSecond ? (
|
||||
videoTierColumns.map((col) => {
|
||||
const tier = priceData.videoTiers?.find(
|
||||
(vt) => vt.key === col.key,
|
||||
);
|
||||
return (
|
||||
<div key={col.key} className='text-right'>
|
||||
<span className='text-sm font-semibold text-emerald-600 dark:text-emerald-400'>
|
||||
{tier?.price || '-'}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
) : isPerImageResolution ? (
|
||||
imageTierColumns.map((col) => {
|
||||
const tier = priceData.imageTiers?.find(
|
||||
(imageTier) => imageTier.key === col.key,
|
||||
);
|
||||
return (
|
||||
<div key={col.key} className='text-right'>
|
||||
<span className='text-sm font-semibold text-sky-600 dark:text-sky-400'>
|
||||
{tier?.price || '-'}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
) : isPerToken ? (
|
||||
<>
|
||||
<div className='text-right'>
|
||||
<span className='text-sm font-semibold text-orange-600 dark:text-orange-400'>
|
||||
{priceData.inputPrice}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-right'>
|
||||
<span className='text-sm font-semibold text-rose-600 dark:text-rose-400'>
|
||||
{priceData.completionPrice || priceData.outputPrice}
|
||||
</span>
|
||||
</div>
|
||||
{extraPriceColumns.map((column) => {
|
||||
const item = priceData.extraPrices?.find(
|
||||
(extra) => extra.key === column.key,
|
||||
);
|
||||
return (
|
||||
<div key={column.key} className='text-right'>
|
||||
<span className='text-sm font-semibold text-sky-600 dark:text-sky-400'>
|
||||
{item?.price || '-'}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
) : (
|
||||
<div className='text-right'>
|
||||
<span className='text-sm font-semibold text-brand-deep dark:text-brand-from'>
|
||||
{priceData.price}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{availableGroups.length === 0 && (
|
||||
<div className='text-center py-4 text-gray-400 dark:text-gray-400 text-xs'>
|
||||
<Coins size={18} className='mx-auto mb-1 opacity-50' />
|
||||
{t('暂无价格信息')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelPricingTable;
|
||||
Reference in New Issue
Block a user