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
- func NewMockEmptyExecutor(_ context.Context, _ core.Step) (executor.Executor, error)
- func NewMockExecutor(_ context.Context, _ core.Step) (executor.Executor, error)
- func RegisterMockExecutors()
- type Executor
- func (e *Executor) GetMessages() []exec.LLMMessage
- func (e *Executor) GetSubRuns() []exec.SubDAGRun
- func (e *Executor) GetToolDefinitions() []exec.ToolDefinition
- func (e *Executor) Kill(sig os.Signal) error
- func (e *Executor) Run(ctx context.Context) error
- func (e *Executor) SetContext(messages []exec.LLMMessage)
- func (e *Executor) SetPushBackContext(inputs map[string]string, iteration int)
- func (e *Executor) SetStderr(out io.Writer)
- func (e *Executor) SetStdout(out io.Writer)
- type MockEmptyExecutor
- func (m *MockEmptyExecutor) GetMessages() []exec.LLMMessage
- func (m *MockEmptyExecutor) Kill(_ os.Signal) error
- func (m *MockEmptyExecutor) Run(_ context.Context) error
- func (m *MockEmptyExecutor) SetContext(_ []exec.LLMMessage)
- func (m *MockEmptyExecutor) SetStderr(_ io.Writer)
- func (m *MockEmptyExecutor) SetStdout(_ io.Writer)
- type MockExecutor
- func (m *MockExecutor) GetMessages() []exec.LLMMessage
- func (m *MockExecutor) Kill(_ os.Signal) error
- func (m *MockExecutor) Run(_ context.Context) error
- func (m *MockExecutor) SetContext(msgs []exec.LLMMessage)
- func (m *MockExecutor) SetStderr(out io.Writer)
- func (m *MockExecutor) SetStdout(out io.Writer)
- type ToolCallResult
- type ToolExecutor
- type ToolRegistry
Constants ¶
const MockEmptyExecutorType = "mock-empty-chat"
MockEmptyExecutorType is a test executor type that returns no messages.
const MockExecutorType = "mock-chat"
MockExecutorType is a test executor type that simulates a successful chat step.
Variables ¶
This section is empty.
Functions ¶
func NewMockEmptyExecutor ¶
NewMockEmptyExecutor creates a mock chat executor that returns no messages.
func NewMockExecutor ¶
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 ¶
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) SetContext ¶
func (e *Executor) SetContext(messages []exec.LLMMessage)
SetContext sets the session context from prior steps.
func (*Executor) SetPushBackContext ¶
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) 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) 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.
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.