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

Function lastEventExample

examples/streaming/main.go:132–140  ·  view source on GitHub ↗

lastEventExample 演示获取最后一个事件

(ctx context.Context, ag *agent.Agent)

Source from the content-addressed store, hash-verified

130
131// lastEventExample 演示获取最后一个事件
132func 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

Callers 1

mainFunction · 0.85

Calls 3

StreamLastFunction · 0.92
PrintfMethod · 0.80
StreamMethod · 0.65

Tested by

no test coverage detected