()
| 19 | ) |
| 20 | |
| 21 | func main() { |
| 22 | ctx := context.Background() |
| 23 | |
| 24 | // 简单的JSON存储 + 本地沙箱 |
| 25 | memStore, err := store.NewJSONStore("./.aster-router") |
| 26 | if err != nil { |
| 27 | log.Fatalf("Failed to create store: %v", err) |
| 28 | } |
| 29 | sbFactory := sandbox.NewFactory() |
| 30 | |
| 31 | // Provider 工厂 |
| 32 | providerFactory := provider.NewMultiProviderFactory() |
| 33 | |
| 34 | // 模板注册:同一个模板 ID,但可以通过 RoutingProfile 决定实际模型 |
| 35 | tplRegistry := agent.NewTemplateRegistry() |
| 36 | tplRegistry.Register(&types.AgentTemplateDefinition{ |
| 37 | ID: "router-demo", |
| 38 | SystemPrompt: "You are a helpful assistant.", |
| 39 | Model: "claude-3-5-sonnet-20241022", |
| 40 | Tools: []string{}, |
| 41 | }) |
| 42 | |
| 43 | // 构造静态路由器: |
| 44 | // - quality-first: 使用 anthropic 的较强模型(示例) |
| 45 | // - cost-first: 使用 deepseek 的模型(示例) |
| 46 | defaultModel := &types.ModelConfig{ |
| 47 | Provider: "anthropic", |
| 48 | Model: "claude-3-5-sonnet-20241022", |
| 49 | } |
| 50 | |
| 51 | routes := []router.StaticRouteEntry{ |
| 52 | { |
| 53 | Task: "chat", |
| 54 | Priority: router.PriorityQuality, |
| 55 | Model: &types.ModelConfig{ |
| 56 | Provider: "anthropic", |
| 57 | Model: "claude-3-5-sonnet-20241022", |
| 58 | }, |
| 59 | }, |
| 60 | { |
| 61 | Task: "chat", |
| 62 | Priority: router.PriorityCost, |
| 63 | Model: &types.ModelConfig{ |
| 64 | Provider: "deepseek", |
| 65 | Model: "deepseek-chat", |
| 66 | }, |
| 67 | }, |
| 68 | } |
| 69 | |
| 70 | rt := router.NewStaticRouter(defaultModel, routes) |
| 71 | |
| 72 | deps := &agent.Dependencies{ |
| 73 | Store: memStore, |
| 74 | SandboxFactory: sbFactory, |
| 75 | ToolRegistry: toolsRegistry(), |
| 76 | ProviderFactory: providerFactory, |
| 77 | Router: rt, |
| 78 | TemplateRegistry: tplRegistry, |
nothing calls this directly
no test coverage detected