feat(llm): 支持原生 Google Gemini API 格式

- 新增 agent/gemini.go 原生 Gemini generateContent / streamGenerateContent?alt=sse llm.Provider,支持流式/非流式、工具调用与 JSON Schema 清洗、thoughtSignature 回传、thinkingConfig(Gemini 2.5 thinkingBudget / Gemini 3+ thinkingLevel)、建连/空响应重试及限流/抓包透传。
- agent.ConfigFrom / FromEnv / Provider() 支持 gemini 格式与 BaseURL 归一化(自动补全 /v1beta 并容忍粘贴完整端点 URL),环境变量支持 GEMINI_API_KEY / GOOGLE_API_KEY。
- db/schema.sql 放开 llm_profiles.format CHECK 约束加入 gemini 并幂等迁移旧库。
- server/server_mgmt.go 模型列表接口支持 Gemini /models(剥离 models/ 前缀并过滤支持 generateContent 的模型)。
- web LLM 配置页与类型/国际化新增 Google Gemini 协议选项及占位提示。
- 补充 agent/gemini_test.go、server/gemini_models_test.go 与限流重试测试。

Fixes #170
This commit is contained in:
ji ruo committed 2026-11-23 18:24:43 +08:00
1 parent 7b196bf683
commit bdd2da919c
13 files changed
+1810 -30

No files matched your search

+1 -1
View File
@@ -423,7 +423,7 @@ func (s *Server) saveLLMConfig(cfg agent.Config) error {
return db.ErrJevProfileJudgeOnly
}
// cfg.Provider() returns one of the chat format strings
// (anthropic / openai / openai-responses), matching the DB CHECK constraint;
// (anthropic / openai / openai-responses / gemini), matching the DB CHECK constraint;
// Jev is intentionally handled by the dedicated intercept path.
format := cfg.Provider()
var id int64