lastEventExample 演示获取最后一个事件
(ctx context.Context, ag *agent.Agent)
| 130 | |
| 131 | // lastEventExample 演示获取最后一个事件 |
| 132 | func lastEventExample(ctx context.Context, ag *agent.Agent) { |
| 133 | // 获取最后一个事件(最终响应) |
| 134 | lastEvent, err := agent.StreamLast(ag.Stream(ctx, "What's the weather?")) |
| 135 | if err != nil { |
| 136 | log.Fatalf("Stream error: %v", err) |
| 137 | } |
| 138 | |
| 139 | fmt.Printf("Final response: %s\n", lastEvent.Content.Content) |
| 140 | } |
| 141 | |
| 142 | // 辅助函数 |
| 143 |
no test coverage detected