mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-17 14:45:11 +08:00
feat: Implement DeepSeek integration, refactor model adapters for streaming and tool calls, enhance admin and account management, and introduce new UI features for settings, API testing, and Vercel sync.
This commit is contained in:
109
webui/src/features/apiTester/ApiTesterContainer.jsx
Normal file
109
webui/src/features/apiTester/ApiTesterContainer.jsx
Normal file
@@ -0,0 +1,109 @@
|
||||
import clsx from 'clsx'
|
||||
|
||||
import { useI18n } from '../../i18n'
|
||||
import { useApiTesterState } from './useApiTesterState'
|
||||
import { useChatStreamClient } from './useChatStreamClient'
|
||||
import ConfigPanel from './ConfigPanel'
|
||||
import ChatPanel from './ChatPanel'
|
||||
|
||||
export default function ApiTesterContainer({ config, onMessage, authFetch }) {
|
||||
const { t } = useI18n()
|
||||
|
||||
const {
|
||||
model,
|
||||
setModel,
|
||||
message,
|
||||
setMessage,
|
||||
apiKey,
|
||||
setApiKey,
|
||||
selectedAccount,
|
||||
setSelectedAccount,
|
||||
response,
|
||||
setResponse,
|
||||
loading,
|
||||
setLoading,
|
||||
streamingContent,
|
||||
setStreamingContent,
|
||||
streamingThinking,
|
||||
setStreamingThinking,
|
||||
isStreaming,
|
||||
setIsStreaming,
|
||||
streamingMode,
|
||||
setStreamingMode,
|
||||
configExpanded,
|
||||
setConfigExpanded,
|
||||
abortControllerRef,
|
||||
} = useApiTesterState({ t })
|
||||
|
||||
const accounts = config.accounts || []
|
||||
const resolveAccountIdentifier = (acc) => {
|
||||
if (!acc || typeof acc !== 'object') return ''
|
||||
return String(acc.identifier || acc.email || acc.mobile || '').trim()
|
||||
}
|
||||
const configuredKeys = config.keys || []
|
||||
const trimmedApiKey = apiKey.trim()
|
||||
const defaultKey = configuredKeys[0] || ''
|
||||
const effectiveKey = trimmedApiKey || defaultKey
|
||||
const customKeyActive = trimmedApiKey !== ''
|
||||
const customKeyManaged = customKeyActive && configuredKeys.includes(trimmedApiKey)
|
||||
|
||||
const models = [
|
||||
{ id: 'deepseek-chat', name: 'deepseek-chat', icon: 'MessageSquare', desc: t('apiTester.models.chat'), color: 'text-amber-500' },
|
||||
{ id: 'deepseek-reasoner', name: 'deepseek-reasoner', icon: 'Cpu', desc: t('apiTester.models.reasoner'), color: 'text-amber-600' },
|
||||
{ id: 'deepseek-chat-search', name: 'deepseek-chat-search', icon: 'SearchIcon', desc: t('apiTester.models.chatSearch'), color: 'text-cyan-500' },
|
||||
{ id: 'deepseek-reasoner-search', name: 'deepseek-reasoner-search', icon: 'SearchIcon', desc: t('apiTester.models.reasonerSearch'), color: 'text-cyan-600' },
|
||||
]
|
||||
|
||||
const { runTest, stopGeneration } = useChatStreamClient({
|
||||
t,
|
||||
onMessage,
|
||||
model,
|
||||
message,
|
||||
effectiveKey,
|
||||
selectedAccount,
|
||||
streamingMode,
|
||||
abortControllerRef,
|
||||
setLoading,
|
||||
setIsStreaming,
|
||||
setResponse,
|
||||
setStreamingContent,
|
||||
setStreamingThinking,
|
||||
})
|
||||
|
||||
return (
|
||||
<div className={clsx('flex flex-col lg:grid lg:grid-cols-12 gap-6 h-[calc(100vh-140px)]')}>
|
||||
<ConfigPanel
|
||||
t={t}
|
||||
configExpanded={configExpanded}
|
||||
setConfigExpanded={setConfigExpanded}
|
||||
models={models}
|
||||
model={model}
|
||||
setModel={setModel}
|
||||
streamingMode={streamingMode}
|
||||
setStreamingMode={setStreamingMode}
|
||||
selectedAccount={selectedAccount}
|
||||
setSelectedAccount={setSelectedAccount}
|
||||
accounts={accounts}
|
||||
resolveAccountIdentifier={resolveAccountIdentifier}
|
||||
apiKey={apiKey}
|
||||
setApiKey={setApiKey}
|
||||
config={config}
|
||||
customKeyActive={customKeyActive}
|
||||
customKeyManaged={customKeyManaged}
|
||||
/>
|
||||
|
||||
<ChatPanel
|
||||
t={t}
|
||||
message={message}
|
||||
setMessage={setMessage}
|
||||
response={response}
|
||||
isStreaming={isStreaming}
|
||||
loading={loading}
|
||||
streamingThinking={streamingThinking}
|
||||
streamingContent={streamingContent}
|
||||
onRunTest={runTest}
|
||||
onStopGeneration={stopGeneration}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user