mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-08 10:25:28 +08:00
feat: add unified response history session management across Claude, Gemini, and OpenAI API backends
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -123,7 +123,6 @@ export function useChatStreamClient({
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${effectiveKey}`,
|
||||
'X-Ds2-Source': 'admin-webui-api-tester',
|
||||
}
|
||||
if (requestAccount) {
|
||||
headers['X-Ds2-Target-Account'] = requestAccount
|
||||
|
||||
@@ -10,6 +10,9 @@ import {
|
||||
VIEW_MODE_KEY,
|
||||
} from './chatHistoryUtils'
|
||||
|
||||
const LIST_REFRESH_MS = 1500
|
||||
const STREAMING_DETAIL_REFRESH_MS = 750
|
||||
|
||||
export default function ChatHistoryContainer({ authFetch, onMessage }) {
|
||||
const { t, lang } = useI18n()
|
||||
const apiFetch = authFetch || fetch
|
||||
@@ -136,7 +139,7 @@ export default function ChatHistoryContainer({ authFetch, onMessage }) {
|
||||
if (!autoRefreshReady || limit === DISABLED_LIMIT) return undefined
|
||||
const timer = window.setInterval(() => {
|
||||
loadList({ mode: 'silent', announceError: false })
|
||||
}, 5000)
|
||||
}, LIST_REFRESH_MS)
|
||||
return () => window.clearInterval(timer)
|
||||
}, [autoRefreshReady, limit])
|
||||
|
||||
@@ -144,7 +147,7 @@ export default function ChatHistoryContainer({ authFetch, onMessage }) {
|
||||
if (!autoRefreshReady || !selectedId || selectedSummary?.status !== 'streaming') return undefined
|
||||
const timer = window.setInterval(() => {
|
||||
loadDetail(selectedId, { announceError: false })
|
||||
}, 1000)
|
||||
}, STREAMING_DETAIL_REFRESH_MS)
|
||||
return () => window.clearInterval(timer)
|
||||
}, [autoRefreshReady, selectedId, selectedSummary?.status])
|
||||
|
||||
|
||||
@@ -207,6 +207,10 @@ function MetaGrid({ selectedItem, t }) {
|
||||
{formatElapsed(selectedItem.elapsed_ms, t)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-lg border border-border bg-card px-3 py-2">
|
||||
<div className="text-[11px] text-muted-foreground">{t('chatHistory.metaSurface')}</div>
|
||||
<div className="text-sm font-medium text-foreground break-all">{selectedItem.surface || t('chatHistory.metaUnknown')}</div>
|
||||
</div>
|
||||
<div className="rounded-lg border border-border bg-card px-3 py-2">
|
||||
<div className="text-[11px] text-muted-foreground">{t('chatHistory.metaModel')}</div>
|
||||
<div className="text-sm font-medium text-foreground break-all">{selectedItem.model || t('chatHistory.metaUnknown')}</div>
|
||||
|
||||
@@ -69,7 +69,7 @@ export function ChatHistoryListPane({ items, selectedItem, deletingId, t, lang,
|
||||
{item.user_input || t('chatHistory.untitled')}
|
||||
</div>
|
||||
<div className="text-[11px] text-muted-foreground mt-1 truncate">
|
||||
{item.model || '-'}
|
||||
{[item.surface, item.model].filter(Boolean).join(' · ') || '-'}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
"desc": "Test API connectivity and responses"
|
||||
},
|
||||
"history": {
|
||||
"label": "Conversations",
|
||||
"desc": "Browse server-side external chat history"
|
||||
"label": "Responses",
|
||||
"desc": "Browse server-side upstream response records"
|
||||
},
|
||||
"import": {
|
||||
"label": "Batch Import",
|
||||
@@ -261,7 +261,7 @@
|
||||
"loading": "Loading conversation history...",
|
||||
"loadFailed": "Failed to load conversation history.",
|
||||
"retentionTitle": "Retention",
|
||||
"retentionDesc": "The server keeps only the latest N external /v1/chat/completions conversations.",
|
||||
"retentionDesc": "The server keeps only the latest N DeepSeek upstream response records across OpenAI Chat, OpenAI Responses, Claude, and Gemini direct interfaces.",
|
||||
"off": "OFF",
|
||||
"refresh": "Refresh",
|
||||
"clearAll": "Clear all",
|
||||
@@ -277,7 +277,7 @@
|
||||
"viewModeList": "List mode",
|
||||
"viewModeMerged": "Merged mode",
|
||||
"emptyTitle": "No conversation history yet",
|
||||
"emptyDesc": "When external clients call /v1/chat/completions, the server will save the results here automatically.",
|
||||
"emptyDesc": "When a supported interface talks to DeepSeek upstream and receives a response, the server saves the result here automatically.",
|
||||
"untitled": "Untitled conversation",
|
||||
"noPreview": "No preview available.",
|
||||
"selectPrompt": "Select a record on the left to view details.",
|
||||
@@ -303,6 +303,7 @@
|
||||
"metaTitle": "Metadata",
|
||||
"metaAccount": "Account",
|
||||
"metaElapsed": "Elapsed",
|
||||
"metaSurface": "Surface",
|
||||
"metaModel": "Model",
|
||||
"metaStatusCode": "Status code",
|
||||
"metaStream": "Output mode",
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
"desc": "测试 API 连接与响应"
|
||||
},
|
||||
"history": {
|
||||
"label": "对话记录",
|
||||
"desc": "查看服务器保存的外部对话历史"
|
||||
"label": "响应记录",
|
||||
"desc": "查看服务器保存的上游响应归档"
|
||||
},
|
||||
"import": {
|
||||
"label": "批量导入",
|
||||
@@ -261,7 +261,7 @@
|
||||
"loading": "正在加载对话记录...",
|
||||
"loadFailed": "加载对话记录失败",
|
||||
"retentionTitle": "保留条数",
|
||||
"retentionDesc": "服务器端只保留最新 N 条外部 /v1/chat/completions 对话记录。",
|
||||
"retentionDesc": "服务器端只保留最新 N 条 DeepSeek 上游响应记录,覆盖 OpenAI Chat、OpenAI Responses、Claude 和 Gemini 直连接口。",
|
||||
"off": "OFF",
|
||||
"refresh": "刷新",
|
||||
"clearAll": "清空全部",
|
||||
@@ -277,7 +277,7 @@
|
||||
"viewModeList": "列表模式",
|
||||
"viewModeMerged": "合并模式",
|
||||
"emptyTitle": "还没有可用的对话记录",
|
||||
"emptyDesc": "当外部客户端调用 /v1/chat/completions 时,服务端会自动把结果写入这里。",
|
||||
"emptyDesc": "当支持的接口与 DeepSeek 上游交互并收到响应时,服务端会自动把结果写入这里。",
|
||||
"untitled": "未命名对话",
|
||||
"noPreview": "暂无预览内容",
|
||||
"selectPrompt": "从左侧选择一条记录查看详情。",
|
||||
@@ -303,6 +303,7 @@
|
||||
"metaTitle": "元信息",
|
||||
"metaAccount": "使用账号",
|
||||
"metaElapsed": "耗时",
|
||||
"metaSurface": "接口",
|
||||
"metaModel": "模型",
|
||||
"metaStatusCode": "状态码",
|
||||
"metaStream": "输出模式",
|
||||
|
||||
Reference in New Issue
Block a user