chat

package
v2.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package chat provides an executor for chat (LLM-based session) steps.

Package chat provides an executor for LLM-based session steps.

Index

Constants

View Source
const MockEmptyExecutorType = "mock-empty-chat"

MockEmptyExecutorType is a test executor type that returns no messages.

View Source
const MockExecutorType = "mock-chat"

MockExecutorType is a test executor type that simulates a successful chat step.

Variables

This section is empty.

Functions

func NewMockEmptyExecutor

func NewMockEmptyExecutor(_ context.Context, _ core.Step) (executor.Executor, error)

NewMockEmptyExecutor creates a mock chat executor that returns no messages.

func NewMockExecutor

func NewMockExecutor(_ context.Context, _ core.Step) (executor.Executor, error)

NewMockExecutor creates a new mock chat executor.

func RegisterMockExecutors

func RegisterMockExecutors()

RegisterMockExecutors registers mock executors for testing.

Types

type Executor

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

Executor implements the executor.Executor interface for chat steps.

func (*Executor) GetMessages

func (e *Executor) GetMessages() []exec.LLMMessage

GetMessages returns the complete session messages after execution. This includes inherited messages, step messages, and the assistant response.

func (*Executor) GetSubRuns

func (e *Executor) GetSubRuns() []exec.SubDAGRun

GetSubRuns returns the collected sub-DAG runs from tool executions. This implements the SubRunProvider interface for UI drill-down functionality.

func (*Executor) GetToolDefinitions

func (e *Executor) GetToolDefinitions() []exec.ToolDefinition

GetToolDefinitions returns the tool definitions that were available to the LLM. This implements the ToolDefinitionProvider interface for UI visibility.

func (*Executor) Kill

func (e *Executor) Kill(sig os.Signal) error

Kill terminates any running tool DAG executions.

func (*Executor) Run

func (e *Executor) Run(ctx context.Context) error

Run executes the chat request.

func (*Executor) SetContext

func (e *Executor) SetContext(messages []exec.LLMMessage)

SetContext sets the session context from prior steps.

func (*Executor) SetPushBackContext

func (e *Executor) SetPushBackContext(inputs map[string]string, iteration int)

func (*Executor) SetStderr

func (e *Executor) SetStderr(out io.Writer)

SetStderr sets the stderr writer.

func (*Executor) SetStdout

func (e *Executor) SetStdout(out io.Writer)

SetStdout sets the stdout writer.

type MockEmptyExecutor

type MockEmptyExecutor struct{}

MockEmptyExecutor is a mock implementation that returns no messages.

func (*MockEmptyExecutor) GetMessages

func (m *MockEmptyExecutor) GetMessages() []exec.LLMMessage

func (*MockEmptyExecutor) Kill

func (m *MockEmptyExecutor) Kill(_ os.Signal) error

func (*MockEmptyExecutor) Run

func (*MockEmptyExecutor) SetContext

func (m *MockEmptyExecutor) SetContext(_ []exec.LLMMessage)

func (*MockEmptyExecutor) SetStderr

func (m *MockEmptyExecutor) SetStderr(_ io.Writer)

func (*MockEmptyExecutor) SetStdout

func (m *MockEmptyExecutor) SetStdout(_ io.Writer)

type MockExecutor

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

MockExecutor is a mock implementation for testing chat message flow.

func (*MockExecutor) GetMessages

func (m *MockExecutor) GetMessages() []exec.LLMMessage

func (*MockExecutor) Kill

func (m *MockExecutor) Kill(_ os.Signal) error

func (*MockExecutor) Run

func (m *MockExecutor) Run(_ context.Context) error

func (*MockExecutor) SetContext

func (m *MockExecutor) SetContext(msgs []exec.LLMMessage)

func (*MockExecutor) SetStderr

func (m *MockExecutor) SetStderr(out io.Writer)

func (*MockExecutor) SetStdout

func (m *MockExecutor) SetStdout(out io.Writer)

type ToolCallResult

type ToolCallResult struct {
	Result core.ToolResult
	SubRun exec1.SubDAGRun
}

ToolCallResult bundles a tool result with sub-DAG run info for tracking. This enables UI drill-down into tool executions.

type ToolExecutor

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

ToolExecutor handles the execution of tool calls by running DAGs.

func NewToolExecutor

func NewToolExecutor(registry *ToolRegistry, workDir string) *ToolExecutor

NewToolExecutor creates a new ToolExecutor with the given registry.

func (*ToolExecutor) ExecuteToolCalls

func (e *ToolExecutor) ExecuteToolCalls(ctx context.Context, toolCalls []llmpkg.ToolCall) []ToolCallResult

ExecuteToolCalls executes multiple tool calls and returns the results. Tool calls are executed sequentially to maintain consistency. Each result includes both the tool result and sub-DAG run info for UI tracking.

func (*ToolExecutor) Kill

func (e *ToolExecutor) Kill(sig os.Signal) error

Kill terminates all running tool DAG executions.

type ToolRegistry

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

ToolRegistry manages tool DAGs and converts them to LLM tool format.

func NewToolRegistry

func NewToolRegistry(ctx context.Context, dagNames []string) (*ToolRegistry, error)

NewToolRegistry creates a ToolRegistry by loading the specified DAGs. dagNames is a list of DAG names to load as tools. Tools are first searched in LocalDAGs (inline definitions with ---), then in the database.

func (*ToolRegistry) GetDAGByToolName

func (r *ToolRegistry) GetDAGByToolName(toolName string) (*core.DAG, bool)

GetDAGByToolName returns the DAG for a given tool name.

func (*ToolRegistry) GetDAGName

func (r *ToolRegistry) GetDAGName(toolName string) (string, bool)

GetDAGName returns the original DAG name for a tool name.

func (*ToolRegistry) HasTools

func (r *ToolRegistry) HasTools() bool

HasTools returns true if any tools are registered.

func (*ToolRegistry) ToLLMTools

func (r *ToolRegistry) ToLLMTools() []llmpkg.Tool

ToLLMTools converts the registry to LLM tool format.

Jump to

Keyboard shortcuts

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