Documentation
¶
Index ¶
- type AgentEvent
- type BaseEvent
- type Context
- func (c *Context) Clone() *Context
- func (c *Context) Context() context.Context
- func (c *Context) Elapsed() time.Duration
- func (c *Context) WithAgentID(agentID string) *Context
- func (c *Context) WithMetadata(key string, value any) *Context
- func (c *Context) WithSessionState(state map[string]any) *Context
- func (c *Context) WithTeamID(teamID string) *Context
- func (c *Context) WithUserID(userID string) *Context
- func (c *Context) WithWorkflowID(workflowID string) *Context
- type Event
- type EventType
- type Input
- func (i *Input) ContentString() string
- func (i *Input) WithAudio(audio ...string) *Input
- func (i *Input) WithFiles(files ...string) *Input
- func (i *Input) WithImages(images ...string) *Input
- func (i *Input) WithMetadata(key string, value any) *Input
- func (i *Input) WithVideos(videos ...string) *Input
- type MetricsEvent
- type Status
- type StatusChangeEvent
- type TeamEvent
- type WorkflowEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentEvent ¶
type AgentEvent struct {
BaseEvent
AgentID string `json:"agent_id,omitempty"`
Content string `json:"content,omitempty"`
Delta string `json:"delta,omitempty"`
Metrics map[string]any `json:"metrics,omitempty"`
}
AgentEvent Agent 事件
type BaseEvent ¶
type BaseEvent struct {
Type EventType `json:"type"`
ID string `json:"run_id"`
Time time.Time `json:"timestamp"`
SessionID string `json:"session_id,omitempty"`
Data map[string]any `json:"data,omitempty"`
}
BaseEvent 基础事件
func NewBaseEvent ¶
NewBaseEvent 创建基础事件
type Context ¶
type Context struct {
// RunID 运行 ID
RunID string
// SessionID 会话 ID
SessionID string
// UserID 用户 ID
UserID string
// AgentID Agent ID
AgentID string
// WorkflowID Workflow ID (如果是 Workflow 运行)
WorkflowID string
// TeamID Team ID (如果是 Team 运行)
TeamID string
// StartTime 开始时间
StartTime time.Time
// Metadata 元数据
Metadata map[string]any
// SessionState 会话状态
SessionState map[string]any
// KnowledgeFilters 知识过滤器
KnowledgeFilters map[string]any
// Dependencies 依赖项
Dependencies map[string]any
// contains filtered or unexported fields
}
Context 运行上下文 - 统一的运行时上下文管理
func NewContextWithContext ¶
NewContextWithContext 使用 Go context 创建运行上下文
func (*Context) WithAgentID ¶
WithAgentID 设置 Agent ID
func (*Context) WithMetadata ¶
WithMetadata 设置元数据
func (*Context) WithSessionState ¶
WithSessionState 设置会话状态
func (*Context) WithTeamID ¶
WithTeamID 设置 Team ID
func (*Context) WithUserID ¶
WithUserID 设置用户 ID
func (*Context) WithWorkflowID ¶
WithWorkflowID 设置 Workflow ID
type Event ¶
type Event interface {
// EventType 返回事件类型
EventType() EventType
// RunID 返回运行 ID
RunID() string
// Timestamp 返回时间戳
Timestamp() time.Time
// ToMap 转换为 map
ToMap() map[string]any
// ToJSON 转换为 JSON
ToJSON() ([]byte, error)
}
Event 统一的运行事件接口
type EventType ¶
type EventType string
EventType 事件类型
const ( // Agent 相关事件 EventAgentStart EventType = "agent.start" EventAgentProgress EventType = "agent.progress" EventAgentToolCall EventType = "agent.tool_call" EventAgentToolResult EventType = "agent.tool_result" EventAgentComplete EventType = "agent.complete" EventAgentError EventType = "agent.error" // Workflow 相关事件 EventWorkflowStart EventType = "workflow.start" EventWorkflowStep EventType = "workflow.step" EventWorkflowComplete EventType = "workflow.complete" EventWorkflowError EventType = "workflow.error" // Team 相关事件 EventTeamStart EventType = "team.start" EventTeamMemberStart EventType = "team.member_start" EventTeamMemberResult EventType = "team.member_result" EventTeamComplete EventType = "team.complete" EventTeamError EventType = "team.error" // 通用事件 EventProgress EventType = "progress" EventStatusChange EventType = "status_change" EventMetrics EventType = "metrics" )
type Input ¶
type Input struct {
// Content 输入内容
Content any
// Images 图片列表
Images []string
// Videos 视频列表
Videos []string
// Audio 音频列表
Audio []string
// Files 文件列表
Files []string
// Metadata 元数据
Metadata map[string]any
// AdditionalMessages 额外消息
AdditionalMessages []any
}
Input 统一的运行输入
func (*Input) WithMetadata ¶
WithMetadata 添加元数据
type MetricsEvent ¶
type MetricsEvent struct {
BaseEvent
TokensUsed int `json:"tokens_used,omitempty"`
TokensInput int `json:"tokens_input,omitempty"`
TokensOutput int `json:"tokens_output,omitempty"`
ExecutionTime float64 `json:"execution_time,omitempty"`
ModelCalls int `json:"model_calls,omitempty"`
ToolCalls int `json:"tool_calls,omitempty"`
}
MetricsEvent 指标事件
type Status ¶
type Status string
Status 运行状态
const ( // StatusPending 待运行 StatusPending Status = "PENDING" // StatusRunning 运行中 StatusRunning Status = "RUNNING" // StatusCompleted 完成 StatusCompleted Status = "COMPLETED" // StatusPaused 暂停 StatusPaused Status = "PAUSED" // StatusCancelled 取消 StatusCancelled Status = "CANCELLED" // StatusError 错误 StatusError Status = "ERROR" // StatusTimeout 超时 StatusTimeout Status = "TIMEOUT" )
type StatusChangeEvent ¶
type StatusChangeEvent struct {
BaseEvent
OldStatus Status `json:"old_status"`
NewStatus Status `json:"new_status"`
Reason string `json:"reason,omitempty"`
}
StatusChangeEvent 状态变更事件
type TeamEvent ¶
type TeamEvent struct {
BaseEvent
TeamID string `json:"team_id,omitempty"`
MemberID string `json:"member_id,omitempty"`
Role string `json:"role,omitempty"`
Metrics map[string]any `json:"metrics,omitempty"`
}
TeamEvent Team 事件
type WorkflowEvent ¶
type WorkflowEvent struct {
BaseEvent
WorkflowID string `json:"workflow_id,omitempty"`
StepID string `json:"step_id,omitempty"`
StepName string `json:"step_name,omitempty"`
StepType string `json:"step_type,omitempty"`
Progress float64 `json:"progress,omitempty"`
Metrics map[string]any `json:"metrics,omitempty"`
}
WorkflowEvent Workflow 事件
Click to show internal directories.
Click to hide internal directories.