feat: VisionTool 集成多模态 LLM 直接调用 — OCR/视觉分析

- VisionTool 改为接受可选 llm.LLMProvider,有模型时直接调用视觉模型分析,
  无模型时回退 base64 data URL 模式,不影响基本功能
- ModelSelector 新增 PurposeVision 路由用途
- main.go 按 vision routing 自动发现并注入视觉模型 provider
- 支持 models.json 中 qwen3.6-flash / qwen-vl-ocr-latest fallback 链

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-24 16:25:56 +08:00
parent 47f9de2409
commit 189f7b999b
3 changed files with 77 additions and 20 deletions
+18 -2
View File
@@ -170,8 +170,24 @@ func main() {
toolRegistry.Register(tools.NewHostSystemTool(hostManager))
}
// Phase 6.3: 视觉理解工具
toolRegistry.Register(tools.NewVisionTool())
// Phase 6.3: 视觉理解工具 — 可选 LLM 增强,无视觉模型时回退 base64 模式
var visionProvider llm.LLMProvider
if configLoader != nil && configLoader.HasConfig() {
cfg := configLoader.GetConfig()
if route, ok := cfg.Routing["vision"]; ok && len(route.FallbackChain) > 0 {
for _, mid := range route.FallbackChain {
if _, ok := cfg.Models[mid]; ok {
visionProvider, _ = modelSelector.Select(context.Background(), llm.PurposeVision)
log.Printf("视觉模型已启用: %s", visionProvider.ModelName())
break
}
}
}
}
if visionProvider == nil {
log.Println("视觉模型未配置,vision_analyze 将使用 base64 模式")
}
toolRegistry.Register(tools.NewVisionTool(visionProvider))
// Phase 6.6: 知识库 RAG 工具
if knowledgeRetriever != nil {