From c282397cd23629eb8fa49420629570a73ae4140a Mon Sep 17 00:00:00 2001 From: Sakura-RanChen <1908198662@qq.com> Date: Mon, 2 Nov 2026 11:09:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dreview=E5=8F=8D?= =?UTF-8?q?=E9=A6=88=E2=80=94=E2=80=94fields=E8=BF=BD=E5=8A=A0=E5=BC=8F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=8E=E5=8D=A0=E4=BD=8D=E7=AC=A6=E5=88=A4?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/db/changelog/202610291451.sql | 14 +++++++++----- main/xiaozhi-server/tests/conftest.py | 5 +++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/main/manager-api/src/main/resources/db/changelog/202610291451.sql b/main/manager-api/src/main/resources/db/changelog/202610291451.sql index 3f7df1644..fd958f605 100644 --- a/main/manager-api/src/main/resources/db/changelog/202610291451.sql +++ b/main/manager-api/src/main/resources/db/changelog/202610291451.sql @@ -1,13 +1,17 @@ --- 为Ollama LLM配置补充api_key键,用于鉴权网关/Ollama Cloud场景 --- 仅在未设置时添加占位值,不覆盖用户已有配置;本地Ollama无需鉴权,保持默认即可 +-- Ollama LLM配置补充api_key占位值,走鉴权网关/Ollama Cloud时使用 UPDATE `ai_model_config` SET `config_json` = JSON_SET(`config_json`, '$.api_key', 'ollama') WHERE `id` = 'LLM_OllamaLLM' AND JSON_EXTRACT(`config_json`, '$.api_key') IS NULL; --- 为Ollama供应商补充api_key字段定义,使管理后台新增/编辑Ollama模型时可直接填写API密钥 --- 仅在fields中尚无api_key时更新,不覆盖其他自定义字段 +-- Ollama供应商追加api_key字段定义,password类型 UPDATE `ai_model_provider` -SET `fields` = '[{"key":"model_name","label":"模型名称","type":"string"},{"key":"base_url","label":"服务地址","type":"string"},{"key":"api_key","label":"API密钥","type":"string"}]' +SET `fields` = JSON_ARRAY_APPEND(COALESCE(`fields`, JSON_ARRAY()), '$', + JSON_OBJECT('key', 'api_key', 'label', 'API密钥', 'type', 'password')) WHERE `id` = 'SYSTEM_LLM_ollama' AND JSON_SEARCH(`fields`, 'one', 'api_key', NULL, '$[*].key') IS NULL; +-- 配置说明补充api_key条目 +UPDATE `ai_model_config` +SET `remark` = CONCAT(`remark`, '\n4. 走鉴权网关或使用Ollama Cloud时,需填写api_key') +WHERE `id` = 'LLM_OllamaLLM' + AND `remark` IS NOT NULL AND `remark` NOT LIKE '%api_key%'; diff --git a/main/xiaozhi-server/tests/conftest.py b/main/xiaozhi-server/tests/conftest.py index a269bb77f..f96f29ad1 100644 --- a/main/xiaozhi-server/tests/conftest.py +++ b/main/xiaozhi-server/tests/conftest.py @@ -184,7 +184,8 @@ def get_provider_type(module: str, provider_name: str | None = None) -> str | No def has_real_key(config: dict, *keys: str) -> bool: """任一候选 key 名下值不是占位符就算有真密钥。 - 占位符判定:空 / "你的..." / 包含 "placeholder" / 字面 "none"。 + 占位符判定:空 / "你的..." / 包含 "placeholder" / 字面 "none" / "ollama" + (Ollama本地服务无需鉴权,config.yaml默认占位值即为"ollama")。 """ if not config: return False @@ -193,7 +194,7 @@ def has_real_key(config: dict, *keys: str) -> bool: if val is None: continue s = str(val).strip().lower() - if not s or s == "none": + if not s or s == "none" or s == "ollama": continue if s.startswith("你的") or "placeholder" in s: continue