feat: add param override audit modal for usage logs

This commit is contained in:
Seefs
2026-03-17 15:47:05 +08:00
parent a4fd2246ba
commit 5db25f47f1
6 changed files with 550 additions and 17 deletions

View File

@@ -19,7 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
import { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Modal } from '@douyinfe/semi-ui';
import { Modal, Button, Tag } from '@douyinfe/semi-ui';
import {
API,
getTodayStartTimestamp,
@@ -181,6 +181,8 @@ export const useLogsData = () => {
] = useState(false);
const [channelAffinityUsageCacheTarget, setChannelAffinityUsageCacheTarget] =
useState(null);
const [showParamOverrideModal, setShowParamOverrideModal] = useState(false);
const [paramOverrideTarget, setParamOverrideTarget] = useState(null);
// Initialize default column visibility
const initDefaultColumns = () => {
@@ -345,6 +347,20 @@ export const useLogsData = () => {
setShowChannelAffinityUsageCacheModal(true);
};
const openParamOverrideModal = (log, other) => {
const lines = Array.isArray(other?.po) ? other.po.filter(Boolean) : [];
if (lines.length === 0) {
return;
}
setParamOverrideTarget({
lines,
modelName: log?.model_name || '',
requestId: log?.request_id || '',
requestPath: other?.request_path || '',
});
setShowParamOverrideModal(true);
};
// Format logs data
const setLogsFormat = (logs) => {
const requestConversionDisplayValue = (conversionChain) => {
@@ -584,6 +600,37 @@ export const useLogsData = () => {
value: other.request_path,
});
}
if (Array.isArray(other?.po) && other.po.length > 0) {
expandDataLocal.push({
key: t('参数覆盖'),
value: (
<div
style={{
display: 'flex',
alignItems: 'center',
gap: 10,
flexWrap: 'wrap',
}}
>
<Tag color='blue' shape='circle'>
{t('{{count}} 项变更', { count: other.po.length })}
</Tag>
<Button
theme='borderless'
type='primary'
size='small'
style={{ paddingLeft: 0 }}
onClick={(event) => {
event.stopPropagation();
openParamOverrideModal(logs[i], other);
}}
>
{t('查看详情')}
</Button>
</div>
),
});
}
if (other?.billing_source === 'subscription') {
const planId = other?.subscription_plan_id;
const planTitle = other?.subscription_plan_title || '';
@@ -811,6 +858,9 @@ export const useLogsData = () => {
setShowChannelAffinityUsageCacheModal,
channelAffinityUsageCacheTarget,
openChannelAffinityUsageCacheModal,
showParamOverrideModal,
setShowParamOverrideModal,
paramOverrideTarget,
// Functions
loadLogs,
@@ -822,6 +872,7 @@ export const useLogsData = () => {
setLogsFormat,
hasExpandableRows,
setLogType,
openParamOverrideModal,
// Translation
t,