types

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Strategy execution stages
	StageInitialization = "initialization"
	StagePreprocessing  = "preprocessing"
	StageExecution      = "execution"
	StageCompleted      = "completed"
	StageFailed         = "failed"

	// Step execution stages
	StepStageStart     = "step_start"
	StepStageExecuting = "step_executing"
	StepStageCompleted = "step_completed"
	StepStageFailed    = "step_failed"

	// Step types
	StepTypeMCPToolCall   = "mcp_tool_call"
	StepTypeLLMProcessing = "llm_processing"
)

Strategy execution stage constants

View Source
const (
	ProgressTypeStrategy = "strategy"
	ProgressTypeStep     = "step"
	ProgressTypeError    = "error"
)

Strategy progress types

Variables

This section is empty.

Functions

This section is empty.

Types

type Plan

type Plan struct {
	ID           string    `json:"id"`
	StrategyName string    `json:"strategy_name"`
	Description  string    `json:"description,omitempty"`
	Steps        []*Step   `json:"steps"`
	CreatedAt    time.Time `json:"created_at"`
	Confidence   float64   `json:"confidence,omitempty"`
}

Plan execution plan

type Query

type Query struct {
	Text    string                 `json:"text"`
	Context map[string]interface{} `json:"context,omitempty"`
	Type    string                 `json:"type,omitempty"`
}

Query structure

type Result

type Result struct {
	PlanID      string                 `json:"plan_id"`
	Success     bool                   `json:"success"`
	StartTime   time.Time              `json:"start_time"`
	EndTime     time.Time              `json:"end_time"`
	Duration    time.Duration          `json:"duration"`
	Steps       []*StepResult          `json:"steps"`
	FinalOutput map[string]interface{} `json:"final_output"`
	Error       string                 `json:"error,omitempty"`
}

Result execution result

type Step

type Step struct {
	ID          string                 `json:"id"`
	Type        string                 `json:"type"` // Use constants: StepTypeMCPToolCall, StepTypeLLMProcessing
	ToolName    string                 `json:"tool_name"`
	Description string                 `json:"description"`
	Params      map[string]interface{} `json:"params"`
	Context     map[string]interface{} `json:"context"`              // Context data (dynamically filled during execution)
	DependsOn   []string               `json:"depends_on,omitempty"` // Dependent step IDs (future expansion)
	Timeout     time.Duration          `json:"timeout,omitempty"`    // Step timeout duration
}

Step execution step

type StepResult

type StepResult struct {
	StepID    string                 `json:"step_id"`
	StepIndex int                    `json:"step_index"`
	Success   bool                   `json:"success"`
	StartTime time.Time              `json:"start_time"`
	EndTime   time.Time              `json:"end_time"`
	Duration  time.Duration          `json:"duration"`
	Output    map[string]interface{} `json:"output"`
	Error     string                 `json:"error,omitempty"`
}

StepResult step execution result

type Strategy

type Strategy interface {
	// Basic information
	Name() string
	Type() string
	Version() string
	Description() string

	// Planning and execution - simplified to only Execute method
	Plan(ctx context.Context, query *Query, mcpClient *mcp.MCPClientWrapper) (*Plan, error)
	Execute(ctx context.Context, plan *Plan, mcpClient *mcp.MCPClientWrapper, llmClient *llm.ChatModelWrapper, progressCallback StrategyProgressCallback) (*Result, error)

	// Configuration
	Configure(config interface{}) error
	Validate() error
}

Strategy interface

type StrategyProgress

type StrategyProgress struct {
	Type       string                 `json:"type"`        // strategy, step, error
	Stage      string                 `json:"stage"`       // Execution stage
	StepIndex  int                    `json:"step_index"`  // Step index (starting from 0, -1 indicates strategy level)
	TotalSteps int                    `json:"total_steps"` // Total number of steps
	Content    string                 `json:"content"`     // Progress description
	Data       map[string]interface{} `json:"data"`        // Additional data
	Error      error                  `json:"error"`       // Error information
	Timestamp  time.Time              `json:"timestamp"`   // Timestamp
	Complete   bool                   `json:"complete"`    // Whether completed
}

StrategyProgress Strategy-layer specific progress report structure Decoupled from SDK main flow, contains only strategy execution related information

type StrategyProgressCallback

type StrategyProgressCallback func(progress *StrategyProgress)

StrategyProgressCallback Strategy progress callback function type Uses strategy-layer specific progress type instead of SDK's StreamingResult

type StrategyRegistry

type StrategyRegistry interface {
	Register(strategy Strategy) error
	Get(strategyName string) (Strategy, bool)
	List() []Strategy
	ListByType(strategyType string) []Strategy
}

StrategyRegistry strategy registry interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL