Documentation
¶
Overview ¶
Package engine defines the framework-agnostic AI provider interfaces.
Index ¶
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 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 {
// Models lists the provider's available models (for the switcher/validation).
Models(ctx context.Context) ([]ModelInfo, error)
// 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"`
}
StreamEvent is one event relayed from a running turn.
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.
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. |
Click to show internal directories.
Click to hide internal directories.