Documentation
¶
Overview ¶
Package engine defines the framework-agnostic AI provider interfaces.
Index ¶
- func Progress(ctx context.Context) func(StreamEvent)
- func WithProgress(ctx context.Context, emit func(StreamEvent)) context.Context
- type ChatRequest
- type EventType
- type Message
- type Provider
- type Role
- type StreamEvent
- type StreamSample
- type StreamSampleOptions
- type ToolCall
- type ToolExecutor
- type ToolSpec
- type Usage
- type WorkspaceInvalidation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Progress ¶
func Progress(ctx context.Context) func(StreamEvent)
Progress returns the emitter attached by WithProgress, or a no-op.
func WithProgress ¶
func WithProgress(ctx context.Context, emit func(StreamEvent)) context.Context
WithProgress attaches an emitter for nested tool progress.
Types ¶
type ChatRequest ¶
type ChatRequest struct {
Model string
System string
Messages []Message
Tools []ToolSpec
MaxSteps int
MaxOutTokens int
}
ChatRequest is one provider turn: system prompt, history, tools, and caps.
type EventType ¶
type EventType string
EventType tags a streamed turn event.
const ( EventTextDelta EventType = "text_delta" EventReasoningDelta EventType = "reasoning_delta" EventToolCall EventType = "tool_call" EventToolResult EventType = "tool_result" EventWorkspaceInvalidated EventType = "workspace_invalidated" EventError EventType = "error" EventDone EventType = "done" )
type Message ¶
type Message struct {
Role Role `json:"role"`
Content string `json:"content"`
// ToolCalls is set on assistant messages that called tools.
ToolCalls []ToolCall `json:"toolCalls,omitempty"`
// ToolCallID + Name identify a tool-result message.
ToolCallID string `json:"toolCallId,omitempty"`
Name string `json:"name,omitempty"`
}
Message is one entry of conversation history passed to the provider.
type Provider ¶
type Provider interface {
// Stream runs one turn, invoking exec for tool calls and emitting events on
// the returned channel until it closes with a done (or error) event.
Stream(ctx context.Context, req ChatRequest, exec ToolExecutor) (<-chan StreamEvent, error)
}
Provider is a configured LLM endpoint capable of streaming a tool-calling turn.
type StreamEvent ¶
type StreamEvent struct {
Type EventType `json:"type"`
Text string `json:"text,omitempty"`
ToolName string `json:"toolName,omitempty"`
ToolID string `json:"toolId,omitempty"`
Input map[string]any `json:"input,omitempty"`
Output any `json:"output,omitempty"`
Err string `json:"err,omitempty"`
Usage *Usage `json:"usage,omitempty"`
// Subagent, when set, marks a tool event as nested work performed by a
// subagent (the UI prefixes it and styles it distinctly).
Subagent string `json:"subagent,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Invalidation *WorkspaceInvalidation `json:"invalidation,omitempty"`
}
StreamEvent is one event relayed from a running turn.
type StreamSample ¶ added in v0.1.1
type StreamSample struct {
RouteID string `json:"routeId"`
StreamID string `json:"streamId,omitempty"`
Kind string `json:"kind,omitempty"`
DurationMS int `json:"durationMs"`
Bytes int `json:"bytes"`
Events int `json:"events"`
Truncated bool `json:"truncated,omitempty"`
Data string `json:"data,omitempty"`
}
StreamSample is the bounded output from an internal read-only stream observer.
type StreamSampleOptions ¶ added in v0.1.1
StreamSampleOptions bounds an internal read-only stream observation.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Input map[string]any `json:"input"`
}
ToolCall is a model-requested invocation of a tool.
type ToolExecutor ¶
ToolExecutor runs a model-requested tool call.
type ToolSpec ¶
type ToolSpec struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]any `json:"parameters"`
}
ToolSpec describes a tool to the model. Parameters is a JSON Schema object.
type WorkspaceInvalidation ¶ added in v0.1.1
type WorkspaceInvalidation struct {
ConnectionID string `json:"connectionId"`
RouteID string `json:"routeId"`
Risk string `json:"risk"`
Params map[string]string `json:"params,omitempty"`
ToolName string `json:"toolName,omitempty"`
ToolID string `json:"toolId,omitempty"`
}
WorkspaceInvalidation tells the browser that connection-scoped data changed.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package eino is the only package that imports cloudwego/eino; it adapts the framework to the engine.Provider seam with an explicit tool-calling loop so each tool call flows through the risk-gated executor.
|
Package eino is the only package that imports cloudwego/eino; it adapts the framework to the engine.Provider seam with an explicit tool-calling loop so each tool call flows through the risk-gated executor. |