diff --git a/CHANGELOG.md b/CHANGELOG.md index 39a7167..21892a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 开发快照 0.1.401(AI 模型连接:当前生效 + 独立草稿) + +### Changed + +- 「系统设置 → AI 模型连接」按交互稿重排:顶部只读「当前生效」(模型 + 服务端真实核验态与地址), + 下方地址/模型是独立草稿;测试草稿只回显核验结果,不更新当前连接,「测试中」与「保存中」分开提示。 +- 保存成功一律用服务端响应回显当前信息;草稿改动或版本冲突(409)都会作废上一次草稿测试, + 冲突时载入最新已保存配置并要求按新版本重测。 +- 已配置密钥默认收起不回显,只有「更换密钥」或首次录入才出现输入框;更换基础地址强制重新录入密钥, + 取消更换无副作用。安全传输与独立密钥存储限制保持不变。 +- 「清除密钥并停用」收进单独折叠区,写明对问答分析与中文翻译的影响并二次确认;只提交已保存连接, + 未保存草稿不会被夹带,取消不产生任何请求。 +- 合并分区标题与组件内重复的说明文字,模型连接说明只保留一处。 + +### Fixed + +- 模型连接的测试/保存不再共用同一个忙碌状态,避免把草稿测试结果误当成已生效配置。 + ## 开发快照 0.1.399(系统设置分区调整:AI 模型连接 / 知识库映射) ### Changed diff --git a/README.md b/README.md index 49b20ec..f61981c 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ make list # 查看检查清单与适用范围 ## 问答运营模型配置 -管理员在「系统设置 → AI 模型连接」填写 OpenAI 兼容基础地址、模型和 API Key。测试连接发送最小非业务请求;保存不会启动历史全量任务,自动分析/翻译默认关闭。密钥不回显,保留、更换和清除分别选择;录入只允许有效 HTTPS 或本机回环连接,不允许跳过证书校验。 +管理员在「系统设置 → AI 模型连接」填写 OpenAI 兼容基础地址、模型和 API Key。页面顶部显示当前已保存的模型与服务端核验结果,下方编辑的是独立草稿:测试连接只核验草稿,保存才更新当前连接,保存成功后按服务端响应回显。测试连接发送最小非业务请求;保存不会启动历史全量任务,自动分析/翻译默认关闭。密钥不回显、默认收起,只有「更换密钥」或首次录入才显示输入框,更换基础地址须重新录入密钥;「清除密钥并停用」在单独折叠区里二次确认,只作用于已保存连接。录入只允许有效 HTTPS 或本机回环连接,不允许跳过证书校验。 API 和普通 worker 须只读挂载同一个独立的 **32 字节、0600 普通文件**,以 `QA_AI_MASTER_KEY_FILE` 指向容器内路径。文件属主应为实际运行 UID;不要复用 Agent 会话存储或把主密钥写进 Compose/Git。治理库只保存加密后的服务密钥;恢复时必须同时恢复治理库和这份独立主密钥。未配置主密钥时如实显示安全存储未就绪。 diff --git a/web/src/QAModelSettings.mounted.test.tsx b/web/src/QAModelSettings.mounted.test.tsx new file mode 100644 index 0000000..78ef46a --- /dev/null +++ b/web/src/QAModelSettings.mounted.test.tsx @@ -0,0 +1,197 @@ +// @vitest-environment jsdom +import { act } from 'react' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { QAModelSettings } from './QAModelSettings' +import type { AISettings } from './qaAITypes' +let root: Root, host: HTMLDivElement +type Call = { path: string; method: string; body: Record | null } +let calls: Call[] +let responder: (call: Call) => { status: number; data?: AISettings; error?: string } +const saved: AISettings = { + revision: 1, + base_url: 'https://model.example.invalid/v1', + model: 'example-model', + key_configured: true, + verification: 'verified', + checked_at: '2026-11-18T10:00:00Z', + automatic_evaluation: true, + automatic_translation: false, + storage_ready: true, +} +const applied = (call: Call, extra: Partial = {}): AISettings => ({ + ...saved, + revision: saved.revision + 1, + base_url: String(call.body?.base_url), + model: String(call.body?.model), + key_configured: call.body?.key_action !== 'clear', + verification: call.body?.key_action === 'clear' ? 'not_configured' : 'verified', + ...extra, +}) +const ok = (data: AISettings) => ({ status: 200, data }) +beforeEach(() => { + Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true }) + host = document.createElement('div') + document.body.append(host) + root = createRoot(host) + calls = [] + responder = (call) => ok(call.method === 'GET' ? saved : applied(call)) + vi.stubGlobal( + 'fetch', + vi.fn(async (path: string, init?: RequestInit) => { + const call: Call = { + path, + method: init?.method ?? 'GET', + body: init?.body ? JSON.parse(String(init.body)) : null, + } + calls.push(call) + const result = responder(call) + return new Response(JSON.stringify(result.error ? { error: result.error } : { data: result.data }), { + status: result.status, + }) + }) + ) +}) +afterEach(async () => { + await act(async () => root.unmount()) + host.remove() + vi.unstubAllGlobals() +}) +const button = (label: string) => { + const found = [...host.querySelectorAll('button')].find((item) => item.textContent?.trim() === label) + expect(found, label).toBeTruthy() + return found! +} +const click = async (label: string) => { + const target = button(label) + await act(async () => target.click()) + await act(async () => {}) +} +const type = async (label: string, value: string) => { + const input = [...host.querySelectorAll('label')] + .find((item) => item.textContent?.startsWith(label)) + ?.querySelector('input') + expect(input, label).toBeTruthy() + await act(async () => { + Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!.call(input, value) + input!.dispatchEvent(new Event('input', { bubbles: true })) + }) +} +const current = () => host.querySelector('.qa-ai-model-current')?.textContent ?? '' +const writes = () => calls.filter((call) => call.method === 'POST') +const disable = async () => { + await click('清除密钥并停用…') + await click('确认清除并停用') +} +describe('AI 模型连接草稿编辑器', () => { + it('tests the draft without touching the saved connection and echoes the server after save', async () => { + await act(async () => root.render()) + expect(current()).toContain('example-model · 已通过真实连接测试') + await type('模型名称', 'draft-model') + await click('测试连接') + const test = writes().at(-1)! + expect(test.path).toBe('/api/v1/qa-ops/ai/settings/test') + expect(test.body).toEqual({ + base_revision: 1, + base_url: saved.base_url, + model: 'draft-model', + key_action: 'keep', + }) + expect(host.textContent).toContain('草稿测试:已通过真实连接测试') + expect(host.textContent).toContain('草稿未保存,当前生效配置未改变') + // 测试不更新「当前生效」,也不产生保存。 + expect(current()).toContain('example-model · 已通过真实连接测试') + expect(writes().filter((call) => call.path.endsWith('/settings'))).toHaveLength(0) + // 再改草稿 ⇒ 上一次测试结论失效。 + await type('模型名称', 'saved-model') + expect(host.textContent).not.toContain('草稿测试:已通过真实连接测试') + await click('保存配置') + const save = writes().at(-1)! + expect(save.path).toBe('/api/v1/qa-ops/ai/settings') + expect(save.body).toEqual({ base_revision: 1, base_url: saved.base_url, model: 'saved-model', key_action: 'keep' }) + // 保存后用服务端响应回显当前信息,而不是本地草稿转写。 + expect(current()).toContain('saved-model · 已通过真实连接测试') + expect(host.textContent).toContain('已保存并更新当前连接:saved-model · 已通过真实连接测试') + expect(host.textContent).toContain('草稿与已保存配置一致') + }) + it('keeps a configured key collapsed and sends a replacement only when asked', async () => { + await act(async () => root.render()) + expect(host.querySelector('input[type=password]')).toBeNull() + await click('更换密钥') + await type('新 API 密钥', 'test-only-replacement-key') + await click('保存配置') + expect(writes().at(-1)!.body).toEqual({ + base_revision: 1, + base_url: saved.base_url, + model: saved.model, + key_action: 'replace', + api_key: 'test-only-replacement-key', + }) + expect(host.querySelector('input[type=password]')).toBeNull() + expect(host.textContent).not.toContain('test-only-replacement-key') + await click('更换密钥') + await click('取消更换') + expect(host.querySelector('input[type=password]')).toBeNull() + expect(host.textContent).toContain('草稿与已保存配置一致') + }) + it('requires a fresh key when the address changes and hides cancelling', async () => { + await act(async () => root.render()) + await type('API 基础地址', 'https://other.example.invalid/v1') + expect(host.querySelector('input[type=password]')).toBeTruthy() + expect(host.textContent).toContain('已更换基础地址:须重新录入密钥') + expect([...host.querySelectorAll('button')].some((item) => item.textContent?.trim() === '取消更换')).toBe(false) + expect(button('保存配置').disabled).toBe(true) + await type('新 API 密钥', 'second-secret') + await click('保存配置') + expect(writes().at(-1)!.body).toEqual({ + base_revision: 1, + base_url: 'https://other.example.invalid/v1', + model: saved.model, + key_action: 'replace', + api_key: 'second-secret', + }) + }) + it('disables only the saved connection, and cancelling the confirmation has no effect', async () => { + await act(async () => root.render()) + await type('模型名称', 'unsaved-draft') + await click('清除密钥并停用…') + await click('取消') + expect(writes()).toHaveLength(0) + expect(current()).toContain('example-model · 已通过真实连接测试') + expect([...host.querySelectorAll('input')].find((item) => item.value === 'unsaved-draft')).toBeTruthy() + await disable() + const clear = writes().at(-1)! + // 草稿里的 unsaved-draft 不会被夹带成停用提交。 + expect(clear.body).toEqual({ + base_revision: 1, + base_url: saved.base_url, + model: saved.model, + key_action: 'clear', + }) + expect(current()).toContain('未配置可用密钥') + expect(host.textContent).toContain('已清除密钥并停用连接') + expect(host.querySelector('input[type=password]')).toBeTruthy() + }) + it('drops a stale draft test when the saved revision changed elsewhere', async () => { + let gets = 0 + responder = (call) => { + if (call.method === 'GET') { + gets += 1 + return ok(gets === 1 ? saved : { ...saved, revision: 2, model: 'other-model' }) + } + return call.path.endsWith('/settings/test') + ? { status: 409, error: '配置、输入、人工复核或预览已变化,请刷新;现有结论未被覆盖' } + : ok(applied(call)) + } + await act(async () => root.render()) + await type('模型名称', 'stale-draft') + await click('测试连接') + expect(host.textContent).toContain('已载入最新已保存配置(版本 2),草稿未保存,请重新测试') + expect(current()).toContain('other-model') + expect(host.textContent).not.toContain('草稿测试:') + // 之后的保存基于刷新后的版本号,不会拿旧 revision 覆盖别人的修改。 + await type('模型名称', 'after-conflict') + await click('保存配置') + expect(writes().at(-1)!.body).toMatchObject({ base_revision: 2, model: 'after-conflict' }) + }) +}) diff --git a/web/src/QAModelSettings.test.tsx b/web/src/QAModelSettings.test.tsx index b116627..2a83571 100644 --- a/web/src/QAModelSettings.test.tsx +++ b/web/src/QAModelSettings.test.tsx @@ -1,37 +1,58 @@ import { it, expect } from 'vitest' import { renderToStaticMarkup } from 'react-dom/server' import { QAModelSettings, qaAIKeyEntryAllowed } from './QAModelSettings' -it('provides independent write-only model settings and does not equate save with bulk execution', () => { +import type { AISettings } from './qaAITypes' +const saved: AISettings = { + revision: 3, + base_url: 'https://model.example.invalid/v1', + model: 'fixture-model', + key_configured: true, + verification: 'verified', + checked_at: '2026-10-19T00:00:00Z', + automatic_evaluation: false, + automatic_translation: false, + storage_ready: true, +} +it('shows the saved connection and keeps a configured key collapsed until replaced', () => { + const html = renderToStaticMarkup() + for (const text of [ + '当前生效', + 'fixture-model · 已通过真实连接测试', + '已配置(不回显)', + '更换密钥', + 'API 基础地址', + '模型名称', + '测试连接', + '保存配置', + '清除密钥并停用连接', + '草稿与已保存配置一致', + ]) + expect(html).toContain(text) + // 已配置的密钥默认收起:没有密码框,也没有把任何密钥值渲染出来。 + expect(html).not.toContain('type="password"') + expect(html).not.toContain('保留现有密钥') + expect(html).not.toContain('fixture-only-api-key') +}) +it('asks for a key on first entry and describes the disable impact', () => { const html = renderToStaticMarkup( ) - for (const text of [ - '问答评估模型', - 'API 基础地址', - '模型名称', - 'API Key', - 'type="password"', - '测试连接', - '保存配置', - '保留现有密钥', - '更换密钥', - '清除密钥', - '保存不会启动全量评估', - ]) - expect(html).toContain(text) - expect(html).not.toContain('value="fixture-only-api-key"') + expect(html).toContain('type="password"') + expect(html).toContain('API 密钥 未配置') + expect(html).toContain('未配置可用密钥') + expect(html).toContain('无法调用此模型') + expect(html).toContain('未保存的草稿不会被提交') + expect(html).toContain('当前没有已保存的密钥') }) it('permits new-key entry only on HTTPS or browser-local loopback origins', () => { expect(qaAIKeyEntryAllowed({ protocol: 'https:', hostname: 'kg.example.invalid' })).toBe(true) diff --git a/web/src/QAModelSettings.tsx b/web/src/QAModelSettings.tsx index ee9c4e3..2ca587c 100644 --- a/web/src/QAModelSettings.tsx +++ b/web/src/QAModelSettings.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react' import type { AISettings } from './qaAITypes' import type { AISettingsInput } from './qaAI' import { fetchAISettings, saveAISettings, testAISettings } from './qaAI' +import { QARequestError } from './qaOps' export function qaAIKeyEntryAllowed(location: { protocol: string; hostname: string }) { return location.protocol === 'https:' || ['localhost', '127.0.0.1', '[::1]', '::1'].includes(location.hostname) } @@ -11,172 +12,303 @@ const verificationLabels: Record = { unverified: '未完成核验,未启用调用', rejected: '服务已拒绝,调用已阻断', } +const when = (value: string) => new Date(value).toLocaleString('zh-CN', { hour12: false }) +type Busy = '' | 'testing' | 'saving' +type Notice = { tone: 'ok' | 'error'; text: string } export function QAModelSettings({ initial }: { initial?: AISettings }) { - const [settings, setSettings] = useState(initial ?? null), - [base, setBase] = useState(initial?.base_url ?? ''), - [model, setModel] = useState(initial?.model ?? '') - const [keyAction, setKeyAction] = useState( - initial?.key_configured ? 'keep' : 'replace' - ), - [key, setKey] = useState('') - const [busy, setBusy] = useState(false), - [error, setError] = useState(null), - [message, setMessage] = useState(null) - const secure = typeof window !== 'undefined' && qaAIKeyEntryAllowed(window.location) + // saved 始终是服务端已生效的那一份(顶部「当前生效」与停用操作的唯一依据); + // 下面的输入只是草稿,测试草稿不回写 saved,避免把未保存的值伪装成当前连接。 + const [saved, setSaved] = useState(initial ?? null) + const [base, setBase] = useState(initial?.base_url ?? '') + const [model, setModel] = useState(initial?.model ?? '') + const [replace, setReplace] = useState(!initial?.key_configured) + const [key, setKey] = useState('') + const [busy, setBusy] = useState('') + const [tested, setTested] = useState(null) + const [confirmingDisable, setConfirmingDisable] = useState(false) + const [notice, setNotice] = useState(null) + const [loadError, setLoadError] = useState(null) useEffect(() => { if (initial) return const controller = new AbortController() void fetchAISettings(controller.signal) .then((value) => { - setSettings(value) + if (controller.signal.aborted) return + setSaved(value) setBase(value.base_url) setModel(value.model) - setKeyAction(value.key_configured ? 'keep' : 'replace') + setReplace(!value.key_configured) }) .catch((reason) => { - if (!controller.signal.aborted) setError(reason instanceof Error ? reason.message : '模型配置读取失败') + if (!controller.signal.aborted) setLoadError(reason instanceof Error ? reason.message : '模型配置读取失败') }) return () => controller.abort() }, [initial]) - const dirty = () => { - setMessage(null) - setError(null) + const secure = typeof window !== 'undefined' && qaAIKeyEntryAllowed(window.location) + const configured = Boolean(saved?.key_configured) + // 服务端规则:保留旧密钥时地址不许变(旧密钥不会被发往新地址),所以换地址强制重新录入。 + const baseChanged = Boolean(saved && base !== saved.base_url) + const keyRequired = !configured || baseChanged || replace + const keyAction: AISettingsInput['key_action'] = keyRequired ? 'replace' : 'keep' + const storageReady = Boolean(saved?.storage_ready) + const keyEntryBlocked = !secure || !storageReady + const dirty = Boolean( + saved && (base !== saved.base_url || model !== saved.model || key !== '' || (configured && replace)) + ) + const ready = + Boolean(saved) && + busy === '' && + base.trim() !== '' && + model.trim() !== '' && + (!keyRequired || (!keyEntryBlocked && key !== '')) + // 任何草稿改动都让上一次测试结果失效:旧草稿的核验结论不能贴在新草稿上。 + const edit = (apply: () => void) => { + apply() + setTested(null) + setNotice(null) } - const run = async (test: boolean) => { - if (!settings) return - setBusy(true) - setMessage(null) - setError(null) - const input: AISettingsInput = { - base_revision: settings.revision, - base_url: base, - model, - key_action: keyAction, - ...(keyAction === 'replace' ? { api_key: key } : {}), + const input = (): AISettingsInput => ({ + base_revision: saved!.revision, + base_url: base, + model, + key_action: keyAction, + ...(keyAction === 'replace' ? { api_key: key } : {}), + }) + const apply = (result: AISettings, prefix: string) => { + setSaved(result) + setBase(result.base_url) + setModel(result.model) + setKey('') + setReplace(!result.key_configured) + setTested(null) + setConfirmingDisable(false) + setNotice({ + tone: 'ok', + text: `${prefix}:${result.model || '未设置模型'} · ${verificationLabels[result.verification]}`, + }) + } + const fail = async (reason: unknown) => { + const message = reason instanceof Error ? reason.message : '模型配置操作失败' + if (!(reason instanceof QARequestError) || reason.status !== 409) { + setNotice({ tone: 'error', text: message }) + return } + // 版本冲突:别人已经改过配置,这份草稿的测试结论作废;草稿本身保留,但必须按最新版本重测。 try { - const result = await (test ? testAISettings(input) : saveAISettings(input)) - if (!test) { - setSettings(result) - setKey('') - setKeyAction(result.key_configured ? 'keep' : 'replace') - } - setMessage( - (test ? '连接测试:' : '配置已保存:') + - verificationLabels[result.verification] + - (test ? ';未保存、未启动任务' : ';保存不会启动全量评估') + const fresh = await fetchAISettings() + setSaved(fresh) + setReplace((current) => current || !fresh.key_configured) + setTested(null) + setNotice({ + tone: 'error', + text: `${message};已载入最新已保存配置(版本 ${fresh.revision}),草稿未保存,请重新测试。`, + }) + } catch { + setNotice({ tone: 'error', text: message }) + } + } + const runTest = async () => { + if (!saved || !ready) return + setBusy('testing') + setNotice(null) + setTested(null) + try { + setTested(await testAISettings(input())) + } catch (reason) { + await fail(reason) + } finally { + setBusy('') + } + } + const runSave = async () => { + if (!saved || !ready) return + setBusy('saving') + setNotice(null) + try { + apply(await saveAISettings(input()), '已保存并更新当前连接') + } catch (reason) { + await fail(reason) + } finally { + setBusy('') + } + } + const runDisable = async () => { + if (!saved || busy !== '') return + setBusy('saving') + setNotice(null) + try { + // 只停用已保存连接:地址与模型取服务端当前值,未保存草稿不参与这次提交。 + apply( + await saveAISettings({ + base_revision: saved.revision, + base_url: saved.base_url, + model: saved.model, + key_action: 'clear', + }), + '已清除密钥并停用连接' ) } catch (reason) { - setError(reason instanceof Error ? reason.message : '模型配置操作失败') + await fail(reason) } finally { - setBusy(false) + setBusy('') } } - const ready = - Boolean(settings) && - !busy && - (keyAction !== 'replace' || (secure && Boolean(key) && Boolean(settings?.storage_ready))) return ( -
-

问答评估模型

-

- 四字段分析和中文问题翻译共用此独立配置。保存不会启动全量评估,也不会自动开启新增处理。 -

- {settings ? ( +
+ {saved ? ( <> -

- {verificationLabels[settings.verification]};密钥:{settings.key_configured ? '已配置(不回显)' : '未配置'} - ;自动分析/翻译:{settings.automatic_evaluation ? '开' : '关'} /{' '} - {settings.automatic_translation ? '开' : '关'} -

-
+
+ 当前生效 + + {saved.model ? `${saved.model} · ` : ''} + {verificationLabels[saved.verification]} + + + {saved.base_url || '未设置地址'} + {saved.checked_at ? ` · 最近核验 ${when(saved.checked_at)}` : ''} + +
+
- -
+ OpenAI 兼容基础地址,不含 /chat/completions。 +
+ API 密钥 {configured ? '已配置(不回显)' : '未配置'} + {configured && !keyRequired ? ( + + ) : null} +
+ {keyRequired ? ( +
+ + {configured && replace && !baseChanged ? ( + + ) : null} +
+ ) : null} + {baseChanged && configured ? ( +

已更换基础地址:须重新录入密钥,原密钥不会发往新地址。

+ ) : null} {!secure ? (

当前不是安全密钥录入连接。请使用有效HTTPS或本机 localhost 地址录入新密钥;不会通过失配证书或普通局域网HTTP发送新密钥。

) : null} - {!settings.storage_ready ? ( + {!storageReady ? (

独立安全存储未就绪,请配置服务器的 QA_AI_MASTER_KEY_FILE;不会读取 Hermes 密钥。

) : null} -
- + +
+ ) : configured ? ( + + ) : ( + 当前没有已保存的密钥。 + )} + +
+ - + {dirty ? '有未保存的修改' : '草稿与已保存配置一致'}
+ + {tested ? ( + + 草稿测试:{verificationLabels[tested.verification]};草稿未保存,当前生效配置未改变。 + + ) : null} + {notice ? ( + + {notice.text} + + ) : null} + - ) : !error ? ( -

读取独立模型配置…

+ ) : !loadError ? ( +

正在读取已保存的模型连接…

) : null} - {message ?

{message}

: null} - {error ? ( + {loadError ? (

- {error} + {loadError}

) : null}
diff --git a/web/src/SystemSettings.test.tsx b/web/src/SystemSettings.test.tsx index 5c295c4..aee2cf8 100644 --- a/web/src/SystemSettings.test.tsx +++ b/web/src/SystemSettings.test.tsx @@ -143,7 +143,12 @@ describe('SystemSettingsView AI 模型连接', () => { ) it('keeps the model connection alone in AI 模型连接 and points WeKnora to 知识库映射', () => { const adminHtml = view('admin') - for (const text of ['AI 模型连接', '问答评估模型', 'WeKnora 的知识库连接已移到「知识库映射」']) { + for (const text of [ + 'AI 模型连接', + '正在读取已保存的模型连接', + '问答四字段分析与中文问题翻译共用此连接', + 'WeKnora 的知识库连接已移到「知识库映射」', + ]) { expect(adminHtml).toContain(text) } // 地址类配置已迁走:这里不再出现 WeKnora 连接表单,也不出现旧的“服务配置”分区名。 @@ -152,7 +157,7 @@ describe('SystemSettingsView AI 模型连接', () => { const engineerHtml = view('engineer') expect(engineerHtml).toContain('仅管理员可修改模型连接') // 工程师看不到模型编辑表单(QAModelSettings 只在管理员下挂载)。 - expect(engineerHtml).not.toContain('问答评估模型') + expect(engineerHtml).not.toContain('正在读取已保存的模型连接') }) }) describe('SystemSettingsView', () => { diff --git a/web/src/SystemSettings.tsx b/web/src/SystemSettings.tsx index 81b6587..26648a3 100644 --- a/web/src/SystemSettings.tsx +++ b/web/src/SystemSettings.tsx @@ -208,13 +208,13 @@ export function SystemSettingsView({

AI 模型连接

-

问答四字段分析与中文问题翻译共用的模型服务;WeKnora 的知识库连接已移到「知识库映射」。

+

+ 问答四字段分析与中文问题翻译共用此连接;保存只更新这份连接,不会自动开启自动分析或自动翻译。 + WeKnora 的知识库连接已移到「知识库映射」。 +

{isAdmin ? : 仅管理员可修改模型连接;密钥不回显。} -

- 保存只更新这份模型连接;自动分析与自动翻译仍按问答运营里的任务开关执行,不会因为保存连接自动打开。 -

) : null} {section === 'knowledge-map' ? ( diff --git a/web/src/qaOps.css b/web/src/qaOps.css index 3f6d781..a86b0af 100644 --- a/web/src/qaOps.css +++ b/web/src/qaOps.css @@ -588,13 +588,6 @@ } } -.qa-ai-model-settings { - padding: 14px 0; - border-block: 1px solid var(--border-base); -} -.qa-ai-model-settings h3 { - margin: 0 0 6px; -} .qa-ai-workbench { border: 1px solid var(--border-base); border-radius: 5px; diff --git a/web/src/systemSettings.css b/web/src/systemSettings.css index d343869..48662b5 100644 --- a/web/src/systemSettings.css +++ b/web/src/systemSettings.css @@ -907,3 +907,93 @@ button.link { color: var(--muted-foreground); font-size: 12px; } + +/* AI 模型连接:上方「当前生效」只读服务端已保存值,下方是独立草稿 */ +.qa-ai-model-settings { + display: grid; + gap: 10px; + padding: 12px 0; + border-block: 1px solid var(--border-base); +} +.qa-ai-model-current { + display: grid; + gap: 3px; +} +.qa-ai-model-current > span { + font-size: 13px; +} +.qa-ai-model-current > small { + color: var(--ink-mute); + overflow-wrap: anywhere; +} +.qa-ai-model-fields { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 10px; +} +.qa-ai-model-fields label, +.qa-ai-model-key-edit label { + display: grid; + gap: 6px; + font-size: 11px; +} +.qa-ai-model-fields input, +.qa-ai-model-key-edit input { + border: 1px solid var(--border-strong); + border-radius: 7px; + padding: 8px; + background: var(--bg-panel); + color: var(--ink-base); + font: inherit; +} +.qa-ai-model-hint, +.qa-ai-model-actions small { + color: var(--ink-mute); +} +.qa-ai-model-key { + display: flex; + align-items: center; + gap: 8px; + flex-wrap: wrap; + font-size: 12px; +} +.qa-ai-model-key-edit { + display: flex; + align-items: end; + gap: 8px; + flex-wrap: wrap; +} +.qa-ai-model-key-edit label { + flex: 1 1 280px; +} +.qa-ai-model-disable p { + margin: 6px 0; + color: var(--ink-mute); + font-size: 11px; +} +.qa-ai-model-disable-actions { + display: flex; + align-items: center; + gap: 8px; + flex-wrap: wrap; +} +.qa-ai-model-actions { + display: flex; + align-items: center; + gap: 8px; + flex-wrap: wrap; +} +.qa-ai-model-test { + display: block; + margin-top: 6px; + color: var(--c-run); + font-size: 12px; +} +.qa-ai-model-settings output { + display: block; +} +@media (max-width: 650px) { + .qa-ai-model-fields { + grid-template-columns: 1fr; + } +}