From 09d4e2f1a1bc206c80d8d3287d070c70ec7fd63d Mon Sep 17 00:00:00 2001
From: chunhualin1 <chunhualin1@lenovo.com>
Date: 星期五, 14 八月 2026 20:00:52 +0800
Subject: [PATCH] Merge branch 'master' of http://git.linmoli.cn/r/Moli.Desktop
---
docs/architecture/llm-command-palette-architecture.md | 93 ++++++++++++++++++++++++++++++++++------------
1 files changed, 69 insertions(+), 24 deletions(-)
diff --git a/docs/architecture/llm-command-palette-architecture.md b/docs/architecture/llm-command-palette-architecture.md
index 2c8f425..d503ddb 100644
--- a/docs/architecture/llm-command-palette-architecture.md
+++ b/docs/architecture/llm-command-palette-architecture.md
@@ -10,13 +10,14 @@
- 鎻掍欢鍓嶇鍙礋璐h緭鍏ャ�佹ā鍨嬮�夋嫨鍜屾祦寮忔覆鏌撱��
- 鎻掍欢鍓嶇鍙紶 `mode`銆乣projectId`銆乣modelId`銆乣messages` 鍜岃姹傚弬鏁帮紝涓嶇洿鎺ヤ紶 provider銆乪ndpoint銆丄PI key銆丄iChat 瀵嗙爜鎴� Session Token銆�
-- 瀹夸富缁存姢 LLM 妯″瀷娉ㄥ唽琛紝姣忎釜妯″瀷鍙嫭绔嬮厤缃� `provider`銆乣endpoint`銆乣authRef` 鍜� `apiModel`銆�
-- 瀹夸富鎸� `modelId` 閫夋嫨 provider adapter锛屽苟鎶婁笉鍚屼緵搴斿晢鐨勬祦寮忓搷搴旂粺涓�杞崲鎴愭彃浠跺彲娑堣垂鐨勪簨浠躲��
+- 瀹夸富缁存姢 LLM 妯″瀷娉ㄥ唽琛紝姣忎釜妯″瀷鍙嫭绔嬮厤缃� `provider`銆乣baseUrl`銆乣authRef` 鍜� `apiModel`銆傛棫閰嶇疆涓殑 `endpoint`锛堝畬鏁� `/chat/completions` URL锛変細瑙勮寖鍖栦负 `baseUrl`銆�
+- 瀹夸富鎸� `modelId` 閫夋嫨 provider adapter锛屽苟鎶婁笉鍚屼緵搴斿晢鐨勬祦寮忓搷搴旂粺涓�杞崲鎴愭彃浠跺彲娑堣垂鐨勪簨浠躲�傝亰澶╄姹傚彂寰� `{baseUrl}/chat/completions`銆�
- API key 涓嶈繘鍏ユ彃浠跺墠绔祫婧愩�乵anifest 绀轰緥鎴栨櫘閫氭棩蹇椼��
- 鎻掍欢杩愯妯″紡鐢遍厤缃喅瀹氾細
- - `provider-direct`锛氭部鐢ㄥ綋鍓嶄緵搴斿晢鐩磋繛閾捐矾锛屽苟鍙皟鐢� AiChat 璁板繂鎺ュ彛绠$悊/鍙洖璁板繂銆�
- - `aichat-api`锛氶�氳繃鑷湁 AiChat API 鐧诲綍銆佽鍙栭」鐩�佸彂閫佽亰澶╁拰璁㈤槄 SSE锛涙彃浠朵晶涓嶅鐞嗚蹇嗐��
-- AiChat 缁熶竴 Host 榛樿鍥哄畾涓� `http://192.168.1.111:13000`锛屼笉浠� AiChat 鎺ュ彛鏂囨。鐨勭幆澧冭〃鎺ㄥ銆�
+ - `provider-direct`锛氭部鐢ㄥ綋鍓嶄緵搴斿晢鐩磋繛閾捐矾锛涗粎鍦ㄥ凡閰嶇疆 AiChat 璐﹀彿鏃惰皟鐢ㄨ蹇嗘帴鍙c��
+ - `aichat-api`锛氶�氳繃鑷湁 AiChat API 鐧诲綍銆佽鍙栭」鐩�佸彂閫佽亰澶╁拰璁㈤槄 SSE锛涙彃浠朵晶涓嶅鐞嗚蹇嗐�侫iChat 璐﹀彿涓庨」鐩潎涓哄彲閫夈��
+- 鎻愪緵鍟嗗彲閰嶇疆 `providers[]`锛屽涓绘寜 `GET {baseUrl}/models` 鎷夊彇妯″瀷鍒楄〃锛涜嚜瀹氫箟 `models[]` 浠嶅彲鎵嬪啓銆�
+- AiChat 缁熶竴 Host 榛樿鍥哄畾涓� `http://192.168.1.111:13000`锛屼粎鏈夐粯璁� `baseUrl` 涓嶇畻宸查厤缃紝涓嶄細鐧诲綍銆�
## Goals
@@ -126,19 +127,27 @@
Bridge->>Runtime: GetLlmModels(pluginId, instanceId)
Runtime->>Llm: GetAvailableModels(pluginId)
Llm->>Registry: Load enabled model summaries
+ Llm->>Llm: Merge custom models[] then providers[] catalogs
Registry-->>Llm: model id, label, provider, supportsStreaming
Llm-->>Runtime: safe model summaries
- Runtime-->>Bridge: summaries without endpoint/authRef
+ Runtime-->>Bridge: summaries without baseUrl/endpoint/authRef
Bridge-->>Plugin: Promise resolve
```
-鎻掍欢妯″瀷涓嬫媺鍙兘鎷垮埌瀹夊叏鎽樿锛�
+鎻掍欢妯″瀷涓嬫媺鍙兘鎷垮埌瀹夊叏鎽樿銆傚睍绀哄悕鐢卞涓绘牸寮忓寲锛�
```json
[
{
- "id": "gpt-5.4",
- "label": "GPT-5.4",
+ "id": "local-qwen",
+ "label": "qwen2.5:14b(Custom)",
+ "provider": "openai-compatible",
+ "supportsStreaming": true,
+ "enabled": true
+ },
+ {
+ "id": "provider:deepseek:deepseek-v4-flash",
+ "label": "deepseek-v4-flash(DeepSeek)",
"provider": "openai-compatible",
"supportsStreaming": true,
"enabled": true
@@ -146,15 +155,15 @@
]
```
-榛樿涓嶈繑鍥� `endpoint`銆乣authRef`銆丄PI key 鎴栧叾浠栨晱鎰熼厤缃�傜鐞嗙獥鍙e彲浠ュ湪鍙楁帶 UI 涓睍绀哄拰缂栬緫 endpoint锛屼絾鎻掍欢鍓嶇涓嶉渶瑕佺煡閬撱��
+榛樿涓嶈繑鍥� `baseUrl`銆乣endpoint`銆乣authRef`銆丄PI key 鎴栧叾浠栨晱鎰熼厤缃�俙providers[]` 涓竴瀹跺け璐ヤ笉褰卞搷鑷畾涔夋ā鍨嬪拰鍏朵粬鎻愪緵鍟嗐��
-`aichat-api` 妯″紡涓嬫ā鍨嬪垪琛ㄦ潵鑷� AiChat `GET /api/chat/models`锛岃繑鍥炲悓鏍风殑瀹夊叏鎽樿缁撴瀯锛�
+`aichat-api` 妯″紡涓嬫ā鍨嬪垪琛ㄦ潵鑷� AiChat `GET /api/chat/models`锛屽睍绀� `{id}(AiChat)`锛涙湭閰嶇疆璐﹀彿鏃朵笉鐧诲綍锛岃繑鍥炵┖鍒楄〃锛�
```json
[
{
"id": "deepseek-v4-flash",
- "label": "deepseek-v4-flash",
+ "label": "deepseek-v4-flash(AiChat)",
"provider": "aichat",
"supportsStreaming": true,
"enabled": true
@@ -175,7 +184,7 @@
Plugin->>Bridge: getProjects()
Bridge->>Runtime: GetAiChatProjects(pluginId, instanceId)
- Runtime->>AiChat: GetProjectsAsync()
+ Runtime->>AiChat: GetProjectsAsync() only when email is configured
AiChat->>Session: EnsureSessionAsync()
Session->>Session: Resolve passwordEnv before password
Session->>Api: POST /api/auth/login
@@ -183,9 +192,19 @@
AiChat->>Api: GET /api/projects with x-session-token
Api-->>AiChat: projects
AiChat-->>Runtime: safe project summaries
- Runtime-->>Bridge: project summaries
+ Runtime-->>Bridge: { status, message, projects }
Bridge-->>Plugin: Promise resolve
```
+
+`llm.getProjects` 鎴愬姛杩斿洖鐘舵�佸寘锛岃�屼笉鏄妸鏈厤缃�/鐧诲綍澶辫触褰撴垚妗ユ帴閿欒锛�
+
+| `status` | 鍓嶇灞曠ず | 鏄惁鐧诲綍 |
+| --- | --- | --- |
+| `not-configured` | `Not configured` | 鍚︼紱浠呮湁榛樿 `baseUrl` 涓嶇畻宸查厤缃� |
+| `not-connected` | `Not connected`锛宼ooltip 涓哄師鍥� | 宸插皾璇曠櫥褰曚絾澶辫触 |
+| `ready` | 鐪熷疄椤圭洰鍚� | 鏄紱涓嶈嚜鍔ㄩ�夌涓�椤癸紝浠呭綋 `defaultProjectId` 浠嶅湪鍒楄〃涓墠閫変腑 |
+
+鏈厤缃� AiChat 鏃朵笉鎻愪緵闀挎湡璁板繂锛歚canUseMemory` / `canViewMemory` / `canManageMemory` 鍏ㄤ负 false锛屼笖涓嶈皟鐢ㄨ蹇嗘煡璇�/鍒涘缓/鍒犻櫎/鍙洖銆俙provider-direct` 浠嶅彲鎸夋墍閫夋ā鍨嬬洿杩炴彁闂��
椤圭洰鎽樿寤鸿鍙繑鍥炴彃浠� UI 闇�瑕佺殑瀛楁锛�
@@ -218,7 +237,7 @@
Runtime->>Runtime: Validate plugin permission llm.stream
Runtime->>Llm: StreamChatAsync(request)
Llm->>Registry: Get model by modelId when provider-direct
- Registry-->>Llm: provider, endpoint, authRef, apiModel
+ Registry-->>Llm: provider, baseUrl, authRef, apiModel
Llm->>Secret: Resolve authRef
Secret-->>Llm: credential or null
Llm->>Adapter: StreamAsync(normalized request)
@@ -335,7 +354,7 @@
"id": "gpt-5.4",
"label": "GPT-5.4",
"provider": "openai-compatible",
- "endpoint": "https://api.openai.example/v1/chat/completions",
+ "baseUrl": "https://api.openai.example/v1",
"authRef": "llm.openai.primary",
"apiModel": "gpt-5.4",
"supportsStreaming": true,
@@ -350,7 +369,7 @@
"id": "deepseek-chat",
"label": "DeepSeek",
"provider": "deepseek",
- "endpoint": "https://api.deepseek.com/chat/completions",
+ "baseUrl": "https://api.deepseek.com",
"authRef": "llm.deepseek.primary",
"apiModel": "deepseek-chat",
"supportsStreaming": true,
@@ -365,7 +384,7 @@
"id": "local-qwen",
"label": "Local Qwen",
"provider": "openai-compatible",
- "endpoint": "http://127.0.0.1:11434/v1/chat/completions",
+ "baseUrl": "http://127.0.0.1:11434/v1",
"authRef": null,
"apiModel": "qwen2.5:14b",
"supportsStreaming": true,
@@ -391,17 +410,38 @@
"aichat": {
"baseUrl": "http://192.168.1.111:13000",
"account": {
- "email": "user@example.com",
+ "email": null,
"password": null,
"passwordEnv": "MOLI_AICHAT_PASSWORD"
},
- "defaultProjectId": "",
+ "defaultProjectId": null,
"memory": {
"enabledInProviderDirect": true,
"defaultScope": "PROJECT",
"recallLimit": 8
}
- }
+ },
+ "providers": [
+ {
+ "id": "deepseek",
+ "label": "DeepSeek",
+ "baseUrl": "https://api.deepseek.com",
+ "authRef": "llm_deepseek_api_key",
+ "enabled": true
+ }
+ ],
+ "models": [
+ {
+ "id": "local-qwen",
+ "label": "qwen2.5:14b",
+ "provider": "openai-compatible",
+ "baseUrl": "http://127.0.0.1:11434/v1",
+ "authRef": null,
+ "apiModel": "qwen2.5:14b",
+ "supportsStreaming": true,
+ "enabled": true
+ }
+ ]
}
```
@@ -411,11 +451,16 @@
| --- | --- |
| `mode` | `provider-direct` 鎴� `aichat-api`锛岀己澶辨椂榛樿涓� `provider-direct` |
| `aichat.baseUrl` | `http` 鎴� `https` 缁濆 URL锛岄粯璁� `http://192.168.1.111:13000` |
-| `aichat.account.email` | 鍙负绌猴紱璋冪敤 AiChat API 鍓嶅繀椤诲瓨鍦� |
+| `aichat.account.email` | 鍙负绌猴紱闈炵┖鎵嶈涓哄凡閰嶇疆 AiChat锛屾墠浼氱櫥褰� |
| `aichat.account.passwordEnv` | 鍙负绌猴紱瀛樺湪鏃朵紭鍏堣鍙栫幆澧冨彉閲� |
| `aichat.account.password` | 鍙负绌猴紱鍙綔涓烘湰鍦版祴璇� fallback |
-| `aichat.defaultProjectId` | 鍙负绌猴紱涓嶄负绌烘椂搴斿瓨鍦ㄤ簬椤圭洰鍒楄〃 |
+| `aichat.defaultProjectId` | 鍙负绌猴紱涓嶄负绌轰笖浠嶅湪椤圭洰鍒楄〃涓墠榛樿閫変腑 |
| `aichat.memory.recallLimit` | `1..20` |
+| `providers[].id` | 鎻愪緵鍟� id锛岀敤浜� `provider:{id}:{apiModel}` |
+| `providers[].label` | 涓嬫媺灞曠ず `apiModel(label)` |
+| `providers[].baseUrl` | OpenAI-compatible 鏍瑰湴鍧�锛涜亰澶╄蛋 `{baseUrl}/chat/completions`锛屾媺妯″瀷璧� `{baseUrl}/models` |
+| `providers[].authRef` | 鍙负绌� |
+| `models[].baseUrl` | 鑷畾涔夋ā鍨嬫牴鍦板潃锛涙棫 `endpoint` 鑻ヤ互 `/chat/completions` 缁撳熬浼氳鑼冨寲涓� `baseUrl` |
瀵嗙爜瑙f瀽椤哄簭锛�
@@ -434,7 +479,7 @@
| `models[].id` | 鍏ㄥ眬鍞竴锛屾帹鑽� `provider-name` 鎴栫敤鎴峰彲璇� id |
| `models[].label` | 1 鍒� 40 瀛楃锛屼緵涓嬫媺灞曠ず |
| `models[].provider` | 蹇呴』瀛樺湪瀵瑰簲 adapter |
-| `models[].endpoint` | 蹇呴』鏄� `http` 鎴� `https` 缁濆 URL |
+| `models[].baseUrl` | 蹇呴』鏄� `http` 鎴� `https` 缁濆 URL锛涙棫 `endpoint` 鍏煎 |
| `models[].authRef` | 鍙负绌猴紱涓嶄负绌烘椂涓嶅緱鍖呭惈鏄庢枃 key |
| `models[].apiModel` | 蹇呭~锛屽彂閫佺粰涓婃父渚涘簲鍟嗙殑鐪熷疄妯″瀷鍚� |
| `models[].timeoutMs` | 寤鸿 `5000..300000` |
--
Gitblit v1.9.1