feat(llm): 引入 rig-core 并建立新 LLM 门面(Ollama 首个打通)

- 依赖改用 rig-core 0.41(仅 reqwest+rustls,不引入 agent/derive)
- 新门面:provider 枚举 + 统一配置 + 单一生成入口 + 凭据校验 + 错误映射
- Ollama 走 rig /api/chat,参数映射与错误文案与旧实现一致
- 用 rig 请求录制 mock 断言请求形状;8 个新单元测试
This commit is contained in:
2026-08-17 15:33:00 +08:00
parent bba15501c6
commit 29c6ff3935
3 changed files with 385 additions and 1 deletions

View File

@@ -34,7 +34,7 @@ which = "6.0"
# HTTP client for LLM APIs
reqwest = { version = "0.12", features = ["json", "rustls-tls", "stream"], default-features = false }
tokio = { version = "1.35", features = ["full"] }
tokio = { version = "1.35", features = ["full", "macros", "rt-multi-thread"] }
# Error handling
thiserror = "1.0"
@@ -76,6 +76,8 @@ edit = "0.1"
# Shell completion generation
shell-words = "1.1"
# LLM integration (rig-core only: HTTP backend + rustls; no agent/derive)
rig-core = { version = "0.41", default-features = false, features = ["reqwest", "rustls"] }
[dev-dependencies]
assert_cmd = "2.0"
@@ -83,6 +85,9 @@ predicates = "3.1"
tempfile = "3.9"
mockall = "0.12"
wiremock = "0.6"
# rig mock HTTP backends for LLM layer tests
rig-core = { version = "0.41", default-features = false, features = ["test-utils"] }
http = "1"
[profile.release]
opt-level = "s"