Documentation
¶
Overview ¶
Package eino wraps the cloudwego/eino ADK (Agent Development Kit) so the Agent Runtime drives completions through an adk.ChatModelAgent + adk.Runner event loop, mirroring the reference runner implementation.
Index ¶
- func EmptyToolCalls(err error) []schema.ToolCall
- func ExpandEnv(s string) string
- func IsEmptyToolCallStream(err error) bool
- type ChatMessage
- type Client
- func (c *Client) Generate(ctx context.Context, prompt string, msgs []ChatMessage, p RunParams) (*Result, error)
- func (c *Client) Model() model.ToolCallingChatModel
- func (c *Client) Name() string
- func (c *Client) Stream(ctx context.Context, prompt string, msgs []ChatMessage, p RunParams, ...) (*Result, error)
- type EmptyToolCallStreamError
- type ModelConfig
- type ModelIdentity
- type ModelUsageRecord
- type Result
- type RunParams
- type StreamChunk
- type StreamStats
- type Usage
- type UsageCollector
- type VisualInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmptyToolCalls ¶ added in v0.1.2
func IsEmptyToolCallStream ¶ added in v0.1.2
Types ¶
type ChatMessage ¶
ChatMessage is a transport-neutral message.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps an eino chat model and runs it through the ADK agent/runner.
func NewClient ¶
func NewClient(ctx context.Context, cfg ModelConfig) (*Client, error)
NewClient builds a chat model from cfg. api_key/api_base support ${ENV_VAR}.
func (*Client) Generate ¶
func (c *Client) Generate(ctx context.Context, prompt string, msgs []ChatMessage, p RunParams) (*Result, error)
Generate performs a non-streaming completion via the ADK event loop.
func (*Client) Model ¶
func (c *Client) Model() model.ToolCallingChatModel
Model returns the underlying tool-calling chat model, for callers (e.g. the dispatcher's sub-agent manager and context compressor) that need direct model access.
func (*Client) Stream ¶
func (c *Client) Stream(ctx context.Context, prompt string, msgs []ChatMessage, p RunParams, onChunk func(StreamChunk) error) (*Result, error)
Stream performs a streaming completion via the ADK event loop, invoking onChunk for each delta. It returns the aggregated content and final usage.
type EmptyToolCallStreamError ¶ added in v0.1.2
type EmptyToolCallStreamError struct {
FinishReason string
Usage Usage
Stats StreamStats
ToolCalls []schema.ToolCall
}
EmptyToolCallStreamError means the provider streamed tool-call deltas, but the ADK stream did not continue into a visible tool result or assistant text.
func (*EmptyToolCallStreamError) Error ¶ added in v0.1.2
func (e *EmptyToolCallStreamError) Error() string
type ModelConfig ¶
type ModelConfig struct {
Provider string
Name string
APIKey string
APIBase string
Temperature float64
MaxTokens int
TopP float64
ExtraFields map[string]any
}
ModelConfig is the subset of model settings the runtime needs to build a chat model.
type ModelIdentity ¶ added in v0.1.5
ModelIdentity identifies the concrete model behind one provider call.
type ModelUsageRecord ¶ added in v0.1.5
type ModelUsageRecord struct {
ModelID string
Provider string
Model string
PromptTokens int
CompletionTokens int
TotalTokens int
RequestCount int
}
ModelUsageRecord is request-scoped usage aggregated for one concrete model.
type Result ¶
type Result struct {
Content string
FinishReason string
Usage Usage
ActionCount int
StreamStats StreamStats
ToolCalls []schema.ToolCall
}
Result is the outcome of a completion.
type RunParams ¶
type RunParams struct {
// Instruction is the system prompt for the agent.
Instruction string
// MaxIterations bounds ChatModel generation cycles (0 => default).
MaxIterations int
// WorkingDir is the base path / working directory bound to filesystem and
// shell tools (Glob, Grep, Read, Edit, Write, Bash, Task*). Empty => ".".
WorkingDir string
// ExtraTools are additional tools (e.g. sub-agent, retriever) appended to
// the built-in tool set for this run.
ExtraTools []tool.BaseTool
// DisableBuiltinTools omits the built-in tool set, using only ExtraTools.
DisableBuiltinTools bool
// VisualInputs are trusted device observations attached to the current user
// turn through Eino's native multimodal message representation.
VisualInputs []VisualInput
// OnAction receives device-bound v2 actions. Actions are control events and
// are never rendered as assistant text.
OnAction func(actionprotocol.Action) error
}
RunParams controls a single agent run.
type StreamStats ¶ added in v0.1.2
type StreamStats struct {
Events int
Chunks int
VisibleChunks int
EmptyChunks int
ToolCallChunks int
ReasoningChunks int
UsageChunks int
}
StreamStats captures what the model stream actually produced. It helps distinguish a real empty model response from tool-call or reasoning-only streams that do not surface user-visible text.
type UsageCollector ¶ added in v0.1.5
type UsageCollector struct {
// contains filtered or unexported fields
}
UsageCollector safely aggregates model calls made by the main Agent, research helpers, context compression, and Sub-Agents in one request.
func UsageCollectorFromContext ¶ added in v0.1.5
func UsageCollectorFromContext(ctx context.Context) *UsageCollector
UsageCollectorFromContext returns the request collector when one is installed.
func WithUsageCollector ¶ added in v0.1.5
func WithUsageCollector(ctx context.Context) (context.Context, *UsageCollector)
WithUsageCollector installs a fresh request-scoped model usage collector.
func (*UsageCollector) Record ¶ added in v0.1.5
func (c *UsageCollector) Record(identity ModelIdentity, usage Usage)
Record adds one completed or attempted provider call to the model aggregate.
func (*UsageCollector) Snapshot ¶ added in v0.1.5
func (c *UsageCollector) Snapshot() []ModelUsageRecord
Snapshot returns a deterministic copy suitable for transport metadata.
func (*UsageCollector) Total ¶ added in v0.1.5
func (c *UsageCollector) Total() Usage
Total returns usage across every model recorded for this request.