feat(llm): 内置 LLM Chat + Agent 工具调用#1206
Open
Jlan45 wants to merge 1 commit into
Open
Conversation
Jlan45
commented
Jun 16, 2026
- model.Config 扩展 LLMConfig 字段(BaseURL/Model/APIKey/SystemPrompt/ MaxTokens/Temperature/EnableLLM),APIKey 用 yaml:'-' 不参与 JSON/YAML 序列化, 通过 LLMAPIKeySet() 计算字段向前端回显存在性。
- 新增 service/singleton/llm.go:LLMClass + Reload + Generate + Stream + AgentRun + AgentStream;基于 cloudwego/eino v0.9.8 + eino-ext OpenAI ChatModel; 配置变更时 Reload 重建 ChatModel;未配置时 IsConfigured 返回 false。
- 新增 service/singleton/llm_tools.go:LLMRegistry + list_servers 工具。 按 DisplayIndex 倒序返回 ID/Name/Note/Online/IP/Platform/Arch/CPU/ MemTotal/DiskTotal,不暴露 agent_secret_key 等敏感字段;支持 keyword/only_online/limit 过滤。
- 新增 controller/llm_chat.go:admin-only SSE 端点 POST /api/v1/llm/chat; 真正的 token-by-token 流式(基于 Stream(),不再切片模拟),自动 合并 tool_calls 并循环执行;tool_call 阶段发 event:tool_call。
- 新增 controller/setting.go::applyLLMTransition:API key 用 *string 实现 PATCH 语义,nil/空 都视为'不修改'(防御性);落盘走 PatchYAMLField 增量写,避免破坏 config.yaml 其它字段。
- 路由注册到 auth group(restScopeMiddleware(ScopeAdminAll)),不嵌入 ConfigDashboard 保证游客/非管理员 response 不回显 api_key。
- 翻译:en_US / zh_CN 加 9 条 LLM 字符串;附带 script/pomo/pomo.go 用 gotext 在没有系统 msgfmt 的环境下编译 .po→.mo。
- 测试:model + service/singleton + cmd/dashboard/controller 全部 PASS, 覆盖 LLMAPIKey 不回显、APIKey PATCH 语义、LLMClass 配置变更、 list_servers 过滤/汇总/排序。
- model.Config 扩展 LLMConfig 字段(BaseURL/Model/APIKey/SystemPrompt/ MaxTokens/Temperature/EnableLLM),APIKey 用 yaml:'-' 不参与 JSON/YAML 序列化, 通过 LLMAPIKeySet() 计算字段向前端回显存在性。 - 新增 service/singleton/llm.go:LLMClass + Reload + Generate + Stream + AgentRun + AgentStream;基于 cloudwego/eino v0.9.8 + eino-ext OpenAI ChatModel; 配置变更时 Reload 重建 ChatModel;未配置时 IsConfigured 返回 false。 - 新增 service/singleton/llm_tools.go:LLMRegistry + list_servers 工具。 按 DisplayIndex 倒序返回 ID/Name/Note/Online/IP/Platform/Arch/CPU/ MemTotal/DiskTotal,不暴露 agent_secret_key 等敏感字段;支持 keyword/only_online/limit 过滤。 - 新增 controller/llm_chat.go:admin-only SSE 端点 POST /api/v1/llm/chat; 真正的 token-by-token 流式(基于 Stream(),不再切片模拟),自动 合并 tool_calls 并循环执行;tool_call 阶段发 event:tool_call。 - 新增 controller/setting.go::applyLLMTransition:API key 用 *string 实现 PATCH 语义,nil/空 都视为'不修改'(防御性);落盘走 PatchYAMLField 增量写,避免破坏 config.yaml 其它字段。 - 路由注册到 auth group(restScopeMiddleware(ScopeAdminAll)),不嵌入 ConfigDashboard 保证游客/非管理员 response 不回显 api_key。 - 翻译:en_US / zh_CN 加 9 条 LLM 字符串;附带 script/pomo/pomo.go 用 gotext 在没有系统 msgfmt 的环境下编译 .po→.mo。 - 测试:model + service/singleton + cmd/dashboard/controller 全部 PASS, 覆盖 LLMAPIKey 不回显、APIKey PATCH 语义、LLMClass 配置变更、 list_servers 过滤/汇总/排序。
Member
|
好家伙 前端pr呢?什么形态,有没有context自动压缩 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.