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

Function demonstrateEventManagement

examples/session/main.go:99–185  ·  view source on GitHub ↗

演示事件管理

(ctx context.Context, service *session.InMemoryService, sessionID string)

Source from the content-addressed store, hash-verified

97
98// 演示事件管理
99func demonstrateEventManagement(ctx context.Context, service *session.InMemoryService, sessionID string) {
100 fmt.Println("📝 Event Management Demo")
101 fmt.Println("========================")
102
103 // 创建多个事件
104 events := []*session.Event{
105 {
106 ID: "evt-001",
107 Timestamp: time.Now(),
108 InvocationID: "inv-001",
109 AgentID: "agent-001",
110 Branch: "main",
111 Author: "user",
112 Content: types.Message{
113 Role: types.RoleUser,
114 Content: "Hello, can you help me?",
115 },
116 },
117 {
118 ID: "evt-002",
119 Timestamp: time.Now().Add(1 * time.Second),
120 InvocationID: "inv-001",
121 AgentID: "agent-001",
122 Branch: "main",
123 Author: "agent-001",
124 Content: types.Message{
125 Role: types.RoleAssistant,
126 Content: "Of course! What do you need help with?",
127 },
128 },
129 {
130 ID: "evt-003",
131 Timestamp: time.Now().Add(2 * time.Second),
132 InvocationID: "inv-001",
133 AgentID: "agent-001",
134 Branch: "main",
135 Author: "agent-001",
136 Content: types.Message{
137 Role: types.RoleAssistant,
138 ToolCalls: []types.ToolCall{
139 {
140 ID: "call-001",
141 Name: "search",
142 Arguments: map[string]any{
143 "query": "golang best practices",
144 },
145 },
146 },
147 },
148 LongRunningToolIDs: []string{"call-001"},
149 },
150 }
151
152 // 添加事件
153 for _, evt := range events {
154 if err := service.AppendEvent(ctx, sessionID, evt); err != nil {
155 log.Printf("Error appending event: %v", err)
156 }

Callers 1

mainFunction · 0.85

Calls 8

PrintfMethod · 0.80
IsFinalResponseMethod · 0.80
AddMethod · 0.65
AppendEventMethod · 0.65
GetMethod · 0.65
EventsMethod · 0.65
LenMethod · 0.65
AllMethod · 0.65

Tested by

no test coverage detected