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

Function runDemo

examples/agent-working-memory/main.go:144–247  ·  view source on GitHub ↗
(ctx context.Context, ag *agent.Agent)

Source from the content-addressed store, hash-verified

142}
143
144func runDemo(ctx context.Context, ag *agent.Agent) {
145 scenarios := []struct {
146 title string
147 prompt string
148 wait time.Duration
149 }{
150 {
151 title: "会话 1: 初次见面,Agent 记住用户信息",
152 prompt: `你好!我是 Alice,一名软件工程师。
153
154我的偏好:
155- 编程语言:TypeScript 和 Go
156- 代码风格:简洁、函数式
157- 回答风格:直接、技术性强
158
159请记住这些信息。`,
160 wait: 3 * time.Second,
161 },
162 {
163 title: "会话 2: 开始一个任务",
164 prompt: `我需要创建一个 REST API 项目。请帮我规划一下步骤。
165
166要求:
167- 使用我偏好的语言
168- 包含基础的 CRUD 操作
169- 有完整的错误处理`,
170 wait: 3 * time.Second,
171 },
172 {
173 title: "会话 3: 查询任务进度",
174 prompt: `我的 REST API 项目进展如何了?还记得我的要求吗?`,
175 wait: 3 * time.Second,
176 },
177 }
178
179 // 自动演示模式
180 if len(os.Args) > 1 && os.Args[1] == "--auto" {
181 fmt.Println("🤖 自动演示模式")
182 fmt.Println("=" + strings.Repeat("=", 60))
183 for i, scenario := range scenarios {
184 fmt.Printf("\n\n%s\n", scenario.title)
185 fmt.Println(strings.Repeat("-", 60))
186 fmt.Printf("[User] %s\n", scenario.prompt)
187
188 _, err := ag.Chat(ctx, scenario.prompt)
189 if err != nil {
190 log.Printf("Error in scenario %d: %v", i+1, err)
191 }
192
193 time.Sleep(scenario.wait)
194 }
195
196 fmt.Println("\n\n" + strings.Repeat("=", 60))
197 fmt.Println("✅ 演示完成!")
198 printAgentStatus(ag)
199 return
200 }
201

Callers 1

mainFunction · 0.70

Calls 4

printAgentStatusFunction · 0.85
PrintfMethod · 0.80
printHelpFunction · 0.70
ChatMethod · 0.45

Tested by

no test coverage detected