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

Method handleSlashCommandForStream

pkg/agent/streaming.go:275–302  ·  view source on GitHub ↗

handleSlashCommandForStream 处理 Slash Command(流式版本)

(ctx context.Context, msg *types.Message, writer *stream.Writer[*session.Event])

Source from the content-addressed store, hash-verified

273
274// handleSlashCommandForStream 处理 Slash Command(流式版本)
275func (a *Agent) handleSlashCommandForStream(ctx context.Context, msg *types.Message, writer *stream.Writer[*session.Event]) (bool, error) {
276 // 检查是否为 slash command
277 if !a.commandExecutor.IsSlashCommand(msg.Content) {
278 return false, nil
279 }
280
281 // 执行 slash command
282 result, err := a.commandExecutor.Execute(ctx, msg.Content, make(map[string]string))
283 if err != nil {
284 return true, err
285 }
286
287 // 生成响应事件
288 event := &session.Event{
289 ID: generateEventID(),
290 Timestamp: a.createdAt,
291 AgentID: a.id,
292 Author: "system",
293 Content: types.Message{
294 Role: types.RoleAssistant,
295 Content: result,
296 },
297 }
298
299 // 发送事件
300 writer.Send(event, nil)
301 return true, nil
302}
303
304// runModelStepStreaming 流式执行模型步骤
305// 返回: (done, error)

Callers 1

StreamMethod · 0.95

Calls 4

IsSlashCommandMethod · 0.80
generateEventIDFunction · 0.70
ExecuteMethod · 0.65
SendMethod · 0.45

Tested by

no test coverage detected