feat(aiops): 模型配置默认 DeepSeek/flash + 模型名真下拉
首次进入配置页自动预填 DeepSeek 端点与 deepseek-flash(只需填 Key);模型名从 datalist 换 shadcn Select(随供应商联动,末项「自定义模型…」转手输)
This commit is contained in:
1 parent
07aa41bc33
commit
b81b31f322
3 files changed
+29
-12
No files matched your search
@@ -58,6 +58,7 @@ export default {
|
||||
},
|
||||
|
||||
config: {
|
||||
customModel: 'Custom model…',
|
||||
advanced: 'Advanced',
|
||||
providerSelectHint: 'Pick a provider to autofill endpoint and model',
|
||||
enabled: 'Enable AI analysis',
|
||||
|
||||
@@ -58,6 +58,7 @@ export default {
|
||||
},
|
||||
|
||||
config: {
|
||||
customModel: '自定义模型…',
|
||||
advanced: '高级设置',
|
||||
providerSelectHint: '选择供应商自动填入端点与推荐模型',
|
||||
enabled: '启用 AI 分析',
|
||||
|
||||
@@ -106,7 +106,14 @@ export default function AiopsPage() {
|
||||
aiApi
|
||||
.getConfig()
|
||||
.then((res: AIConfigResponse) => {
|
||||
setConfig(res.config)
|
||||
const cfg = res.config
|
||||
// 首次配置默认 DeepSeek + 最新 flash:用户只需填 API Key
|
||||
if (cfg && !cfg.baseUrl && !cfg.model) {
|
||||
const deepseek = LLM_PROVIDERS.find(p => p.id === 'deepseek')!
|
||||
cfg.baseUrl = deepseek.endpoint
|
||||
cfg.model = 'deepseek-flash'
|
||||
}
|
||||
setConfig(cfg)
|
||||
setEnabled(Boolean(res.config?.enabled))
|
||||
setRedactText((res.config?.redactExtra ?? []).join('\n'))
|
||||
setUsedToday(res.tokenUsedToday ?? 0)
|
||||
@@ -540,17 +547,25 @@ export default function AiopsPage() {
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs">{t('config.model')}</Label>
|
||||
<Input
|
||||
value={config.model}
|
||||
placeholder="deepseek-flash"
|
||||
list="llm-model-options"
|
||||
onChange={e => setConfig({ ...config, model: e.target.value })}
|
||||
/>
|
||||
<datalist id="llm-model-options">
|
||||
{(LLM_PROVIDERS.find(p => p.id === matchProvider(config.baseUrl))?.models ?? []).map(m => (
|
||||
<option key={m} value={m} />
|
||||
))}
|
||||
</datalist>
|
||||
{((LLM_PROVIDERS.find(p => p.id === matchProvider(config.baseUrl))?.models ?? ['deepseek-flash'])).includes(config.model) || !config.model ? (
|
||||
<Select
|
||||
value={config.model || ((LLM_PROVIDERS.find(p => p.id === matchProvider(config.baseUrl))?.models ?? ['deepseek-flash']))[0]}
|
||||
onValueChange={value => {
|
||||
if (value === '__custom__') { setConfig({ ...config, model: '' }); return }
|
||||
setConfig({ ...config, model: value })
|
||||
}}
|
||||
>
|
||||
<SelectTrigger><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
{((LLM_PROVIDERS.find(p => p.id === matchProvider(config.baseUrl))?.models ?? ['deepseek-flash'])).map(m => (
|
||||
<SelectItem key={m} value={m}>{m}</SelectItem>
|
||||
))}
|
||||
<SelectItem value="__custom__">{t('config.customModel')}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
) : (
|
||||
<Input value={config.model} placeholder="model-name" onChange={e => setConfig({ ...config, model: e.target.value })} />
|
||||
)}
|
||||
<p className="text-[11px] text-muted-foreground">{t('config.modelHint')}</p>
|
||||
</div>
|
||||
{matchProvider(config.baseUrl) === 'custom' && (
|
||||
|
||||
Reference in new issue
Block a user