feat(aiops): 模型配置默认 DeepSeek/flash + 模型名真下拉

首次进入配置页自动预填 DeepSeek 端点与 deepseek-flash(只需填 Key);模型名从
datalist 换 shadcn Select(随供应商联动,末项「自定义模型…」转手输)
This commit is contained in:
opsx committed 2026-10-31 23:41:43 +08:00
1 parent 07aa41bc33
commit b81b31f322
3 files changed
+28 -11

No files matched your search

+1
View File
@@ -58,6 +58,7 @@ export default {
}, },
config: { config: {
customModel: 'Custom model…',
advanced: 'Advanced', advanced: 'Advanced',
providerSelectHint: 'Pick a provider to autofill endpoint and model', providerSelectHint: 'Pick a provider to autofill endpoint and model',
enabled: 'Enable AI analysis', enabled: 'Enable AI analysis',
+1
View File
@@ -58,6 +58,7 @@ export default {
}, },
config: { config: {
customModel: '自定义模型…',
advanced: '高级设置', advanced: '高级设置',
providerSelectHint: '选择供应商自动填入端点与推荐模型', providerSelectHint: '选择供应商自动填入端点与推荐模型',
enabled: '启用 AI 分析', enabled: '启用 AI 分析',
+26 -11
View File
@@ -106,7 +106,14 @@ export default function AiopsPage() {
aiApi aiApi
.getConfig() .getConfig()
.then((res: AIConfigResponse) => { .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)) setEnabled(Boolean(res.config?.enabled))
setRedactText((res.config?.redactExtra ?? []).join('\n')) setRedactText((res.config?.redactExtra ?? []).join('\n'))
setUsedToday(res.tokenUsedToday ?? 0) setUsedToday(res.tokenUsedToday ?? 0)
@@ -540,17 +547,25 @@ export default function AiopsPage() {
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label className="text-xs">{t('config.model')}</Label> <Label className="text-xs">{t('config.model')}</Label>
<Input {((LLM_PROVIDERS.find(p => p.id === matchProvider(config.baseUrl))?.models ?? ['deepseek-flash'])).includes(config.model) || !config.model ? (
value={config.model} <Select
placeholder="deepseek-flash" value={config.model || ((LLM_PROVIDERS.find(p => p.id === matchProvider(config.baseUrl))?.models ?? ['deepseek-flash']))[0]}
list="llm-model-options" onValueChange={value => {
onChange={e => setConfig({ ...config, model: e.target.value })} if (value === '__custom__') { setConfig({ ...config, model: '' }); return }
/> setConfig({ ...config, model: value })
<datalist id="llm-model-options"> }}
{(LLM_PROVIDERS.find(p => p.id === matchProvider(config.baseUrl))?.models ?? []).map(m => ( >
<option key={m} value={m} /> <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>
))} ))}
</datalist> <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> <p className="text-[11px] text-muted-foreground">{t('config.modelHint')}</p>
</div> </div>
{matchProvider(config.baseUrl) === 'custom' && ( {matchProvider(config.baseUrl) === 'custom' && (