batch

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportTrajectories

func ExportTrajectories(results []TaskResult, format string) ([]byte, error)

ExportTrajectories exports trajectories for RL training

Types

type Config

type Config struct {
	MaxConcurrent int           // Max parallel jobs
	RetryCount    int           // Number of retries on failure
	RetryDelay    time.Duration // Delay between retries
	ResultDir     string        // Directory to save results
	ProgressDir   string        // Directory to save progress
	Timeout       time.Duration // Job timeout
}

Config holds batch configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default configuration

type Job

type Job struct {
	ID             string                 `json:"id"`
	Name           string                 `json:"name"`
	Type           string                 `json:"type"` // trajectory, query, skill
	InputFile      string                 `json:"input_file"`
	OutputFile     string                 `json:"output_file"`
	Params         map[string]interface{} `json:"params"`
	Status         string                 `json:"status"`   // pending, running, completed, failed
	Progress       float64                `json:"progress"` // 0-100
	CreatedAt      time.Time              `json:"created_at"`
	StartedAt      *time.Time             `json:"started_at,omitempty"`
	CompletedAt    *time.Time             `json:"completed_at,omitempty"`
	Error          string                 `json:"error,omitempty"`
	RetryCount     int                    `json:"retry_count"`
	TotalItems     int                    `json:"total_items"`
	ProcessedItems int                    `json:"processed_items"`
}

Job represents a batch job

type JobResult

type JobResult struct {
	JobID       string         `json:"job_id"`
	Success     bool           `json:"success"`
	OutputFile  string         `json:"output_file"`
	Results     []TaskResult   `json:"results,omitempty"`
	Errors      []TaskError    `json:"errors,omitempty"`
	Summary     *ResultSummary `json:"summary,omitempty"`
	Duration    time.Duration  `json:"duration"`
	ProcessedAt time.Time      `json:"processed_at"`
}

JobResult contains job execution results

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles batch processing operations

func NewManager

func NewManager(config *Config) *Manager

NewManager creates a new batch manager

func (*Manager) CancelJob

func (m *Manager) CancelJob(jobID string) error

CancelJob cancels a running job

func (*Manager) CreateJob

func (m *Manager) CreateJob(jobType string, inputFile string, params map[string]interface{}) (*Job, error)

CreateJob creates a new batch job

func (*Manager) DeleteJob

func (m *Manager) DeleteJob(jobID string) error

DeleteJob removes a job

func (*Manager) ExportResults

func (m *Manager) ExportResults(jobID string, format string) ([]byte, error)

ExportResults exports job results to various formats

func (*Manager) GetJob

func (m *Manager) GetJob(id string) *Job

GetJob returns a job by ID

func (*Manager) ListJobs

func (m *Manager) ListJobs() []*Job

ListJobs returns all jobs

func (*Manager) LoadProgress

func (m *Manager) LoadProgress(jobID string) (*Job, error)

LoadProgress loads job progress from file

func (*Manager) ResultChan

func (m *Manager) ResultChan() <-chan *JobResult

ResultChan returns the result channel

func (*Manager) RunJob

func (m *Manager) RunJob(ctx context.Context, jobID string) (*JobResult, error)

RunJob executes a job

type QueryJob

type QueryJob struct {
	Job
	Tasks []QueryTask `json:"tasks"`
}

QueryJob represents a batch query job

type QueryTask

type QueryTask struct {
	TaskID   string  `json:"task_id"`
	Query    string  `json:"query"`
	Response string  `json:"response,omitempty"`
	Tokens   int     `json:"tokens"`
	Cost     float64 `json:"cost"`
	Success  bool    `json:"success"`
	Error    string  `json:"error,omitempty"`
}

QueryTask is a single query task

type ResultSummary

type ResultSummary struct {
	TotalTasks      int           `json:"total_tasks"`
	Successful      int           `json:"successful"`
	Failed          int           `json:"failed"`
	SuccessRate     float64       `json:"success_rate"`
	TotalDuration   time.Duration `json:"total_duration"`
	AvgTaskDuration time.Duration `json:"avg_task_duration"`
	TotalTokens     int64         `json:"total_tokens"`
	TotalCost       float64       `json:"total_cost"`
}

ResultSummary summarizes batch results

type TaskError

type TaskError struct {
	TaskID string      `json:"task_id"`
	Error  string      `json:"error"`
	Input  interface{} `json:"input"`
}

TaskError represents a task error

type TaskResult

type TaskResult struct {
	TaskID   string                 `json:"task_id"`
	Input    interface{}            `json:"input"`
	Output   interface{}            `json:"output"`
	Duration time.Duration          `json:"duration"`
	Success  bool                   `json:"success"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

TaskResult represents a single task result

type ToolCall

type ToolCall struct {
	ID        string                 `json:"id"`
	Name      string                 `json:"name"`
	Arguments map[string]interface{} `json:"arguments"`
}

ToolCall represents a tool call in trajectory

type TrajectoryJob

type TrajectoryJob struct {
	Job
	Tasks []TrajectoryTask `json:"tasks"`
}

TrajectoryJob represents a trajectory generation job

type TrajectoryStep

type TrajectoryStep struct {
	Step       int        `json:"step"`
	Role       string     `json:"role"` // user, assistant, tool
	Content    string     `json:"content"`
	ToolCalls  []ToolCall `json:"tool_calls,omitempty"`
	ToolResult string     `json:"tool_result,omitempty"`
	Timestamp  time.Time  `json:"timestamp"`
}

TrajectoryStep represents a single step in trajectory

type TrajectoryTask

type TrajectoryTask struct {
	TaskID        string           `json:"task_id"`
	Query         string           `json:"query"`
	SystemPrompt  string           `json:"system_prompt,omitempty"`
	Tools         []string         `json:"tools,omitempty"`
	MaxSteps      int              `json:"max_steps,omitempty"`
	ExpectedTools []string         `json:"expected_tools,omitempty"`
	Trajectory    []TrajectoryStep `json:"trajectory,omitempty"`
	Success       bool             `json:"success"`
	Error         string           `json:"error,omitempty"`
}

TrajectoryTask is a single trajectory generation task

Jump to

Keyboard shortcuts

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