MCPcopy Create free account
hub / github.com/astercloud/aster / createDependencies

Function createDependencies

examples/prompt-builder/main.go:82–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80}
81
82func createDependencies() *agent.Dependencies {
83 // 创建工具注册表并注册内置工具
84 toolRegistry := tools.NewRegistry()
85 builtin.RegisterAll(toolRegistry)
86
87 // 创建模板注册表
88 templateRegistry := agent.NewTemplateRegistry()
89
90 // 注册代码助手模板
91 templateRegistry.Register(&types.AgentTemplateDefinition{
92 ID: "code-assistant",
93 SystemPrompt: "You are a professional code assistant. Help users with software development tasks.",
94 Tools: []any{"Read", "Write"},
95 })
96
97 // 注册研究助手模板
98 templateRegistry.Register(&types.AgentTemplateDefinition{
99 ID: "research-assistant",
100 SystemPrompt: "You are a research assistant. Help users gather and analyze information.",
101 Tools: []any{"Read"},
102 })
103
104 // 注册带 Todo 提醒的模板
105 templateRegistry.Register(&types.AgentTemplateDefinition{
106 ID: "todo-assistant",
107 SystemPrompt: "You are a task management assistant.",
108 Tools: []any{"Read", "Write"},
109 Runtime: &types.AgentTemplateRuntime{
110 Todo: &types.TodoConfig{
111 Enabled: true,
112 ReminderOnStart: true,
113 },
114 },
115 })
116
117 // 创建 Provider Factory
118 providerFactory := provider.NewMultiProviderFactory()
119
120 // 创建 Sandbox Factory
121 sandboxFactory := sandbox.NewFactory()
122
123 // 创建 Store
124 jsonStore, err := store.NewJSONStore(".aster-prompt-builder")
125 if err != nil {
126 log.Fatalf("Failed to create store: %v", err)
127 }
128
129 return &agent.Dependencies{
130 ToolRegistry: toolRegistry,
131 TemplateRegistry: templateRegistry,
132 ProviderFactory: providerFactory,
133 SandboxFactory: sandboxFactory,
134 Store: jsonStore,
135 }
136}
137
138// getSystemPrompt 获取 Agent 的 System Prompt
139func getSystemPrompt(ag *agent.Agent) string {

Callers 1

mainFunction · 0.70

Calls 7

RegisterMethod · 0.95
NewRegistryFunction · 0.92
RegisterAllFunction · 0.92
NewTemplateRegistryFunction · 0.92
NewMultiProviderFactoryFunction · 0.92
NewFactoryFunction · 0.92
NewJSONStoreFunction · 0.92

Tested by

no test coverage detected