/*
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 .
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import {
Avatar,
Button,
Space,
Tag,
Tooltip,
Popover,
Typography,
} from '@douyinfe/semi-ui';
import {
timestamp2string,
renderGroup,
renderQuota,
stringToColor,
getLogOther,
renderModelTag,
renderClaudeLogContent,
renderLogContent,
renderModelPriceSimple,
renderAudioModelPrice,
renderClaudeModelPrice,
renderModelPrice,
} from '../../../helpers';
import { IconHelpCircle, IconStarStroked } from '@douyinfe/semi-icons';
import { Route } from 'lucide-react';
const colors = [
'amber',
'blue',
'cyan',
'green',
'grey',
'indigo',
'light-blue',
'lime',
'orange',
'pink',
'purple',
'red',
'teal',
'violet',
'yellow',
];
function formatRatio(ratio) {
if (ratio === undefined || ratio === null) {
return '-';
}
if (typeof ratio === 'number') {
return ratio.toFixed(4);
}
return String(ratio);
}
function buildChannelAffinityTooltip(affinity, t) {
if (!affinity) {
return null;
}
const keySource = affinity.key_source || '-';
const keyPath = affinity.key_path || affinity.key_key || '-';
const keyHint = affinity.key_hint || '';
const keyFp = affinity.key_fp ? `#${affinity.key_fp}` : '';
const keyText = `${keySource}:${keyPath}${keyFp}`;
const lines = [
t('渠道亲和性'),
`${t('规则')}:${affinity.rule_name || '-'}`,
`${t('分组')}:${affinity.selected_group || '-'}`,
`${t('Key')}:${keyText}`,
...(keyHint ? [`${t('Key 摘要')}:${keyHint}`] : []),
];
return (
{lines.map((line, i) => (
{line}
))}
);
}
// Render functions
function renderType(type, t) {
switch (type) {
case 1:
return (
{t('充值')}
);
case 2:
return (
{t('消费')}
);
case 3:
return (
{t('管理')}
);
case 4:
return (
{t('系统')}
);
case 5:
return (
{t('错误')}
);
default:
return (
{t('未知')}
);
}
}
function renderIsStream(bool, t) {
if (bool) {
return (
{t('流')}
);
} else {
return (
{t('非流')}
);
}
}
function renderUseTime(type, t) {
const time = parseInt(type);
if (time < 101) {
return (
{' '}
{time} s{' '}
);
} else if (time < 300) {
return (
{' '}
{time} s{' '}
);
} else {
return (
{' '}
{time} s{' '}
);
}
}
function renderFirstUseTime(type, t) {
let time = parseFloat(type) / 1000.0;
time = time.toFixed(1);
if (time < 3) {
return (
{' '}
{time} s{' '}
);
} else if (time < 10) {
return (
{' '}
{time} s{' '}
);
} else {
return (
{' '}
{time} s{' '}
);
}
}
function renderModelName(record, copyText, t) {
let other = getLogOther(record.other);
let modelMapped =
other?.is_model_mapped &&
other?.upstream_model_name &&
other?.upstream_model_name !== '';
if (!modelMapped) {
return renderModelTag(record.model_name, {
onClick: (event) => {
copyText(event, record.model_name).then((r) => {});
},
});
} else {
return (
<>