config

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveSystemPrompt

func ResolveSystemPrompt(cfg *Config, prompt string) (string, error)

ResolveSystemPrompt resolves a system prompt reference. If the prompt starts with "@file:", the remainder is treated as a file path and its contents are returned. If the prompt matches a key in the top-level systemPrompts map, the referenced value is returned. Otherwise the prompt string is returned as-is.

Types

type Chat

type Chat struct {
	Desc                 string        `yaml:"desc"`
	System               string        `yaml:"system"`
	InitSystem           string        `yaml:"initSystem,omitempty"` // System prompt for the first round (no context)
	Model                string        `yaml:"model"`
	MaxMessageRounds     int           `yaml:"maxMessageRounds"`
	ContextMode          string        `yaml:"contextMode,omitempty"`          // context overflow mode: "compress" (default), "truncate" or "window"
	MaxContextTokens     int           `yaml:"maxContextTokens,omitempty"`     // model context window size in tokens (window mode)
	ContextCompressRatio float64       `yaml:"contextCompressRatio,omitempty"` // fraction of the window that triggers compression (window mode, default 0.8)
	MaxIterations        int           `yaml:"maxIterations"`
	MaxRetries           int           `yaml:"maxRetries"`
	MCPServers           []string      `yaml:"mcpServers,omitempty"`
	Skill                *Skill        `yaml:"skill,omitempty"`
	Tools                []string      `yaml:"tools,omitempty"`
	Default              bool          `yaml:"default"`
	Hooks                *SessionHooks `yaml:"hooks,omitempty"`
	Cron                 []CronTask    `yaml:"cron,omitempty"`
	Persistence          bool          `yaml:"persistence"`
}

type Config

type Config struct {
	Chats         map[string]Chat      `yaml:"chats,omitempty"`
	Providers     map[string]Provider  `yaml:"providers,omitempty"`
	Models        map[string]Model     `yaml:"models,omitempty"`
	MCPServers    map[string]MCPServer `yaml:"mcpServers,omitempty"`
	Tools         map[string]Tool      `yaml:"tools,omitempty"`
	SystemPrompts map[string]string    `yaml:"systemPrompts,omitempty"`
	// ChatOrder records the chat names in the order they appear in the config
	// file. YAML mapping nodes preserve document order in their node tree, but
	// that order is lost once decoded into the Chats map, so it is captured
	// here during unmarshaling. Populated only when loaded from YAML.
	ChatOrder []string `yaml:"-"`
}

Config represents the configuration for Eino CLI

func GetConfig

func GetConfig() *Config

GetConfig gets global configuration

func LoadConfig

func LoadConfig(configPath string) (*Config, error)

LoadConfig loads configuration from file and saves to global variable

func (*Config) DeepCopy added in v1.8.0

func (c *Config) DeepCopy() (*Config, error)

DeepCopy returns an independent deep copy of the configuration via a JSON round-trip. Every field of Config is a plain value, a map or a slice of such values (including map[string]any), so JSON round-tripping produces a fully detached copy with no shared references.

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom YAML unmarshaling for backward compatibility. It normalizes snake_case keys to camelCase so both styles are accepted.

type CronTask added in v1.8.0

type CronTask struct {
	Expr   string             `yaml:"expr"`
	Prompt string             `yaml:"prompt"`
	Hook   *SessionHookConfig `yaml:"hook,omitempty"`
}

CronTask defines a scheduled task for a chat. When the cron expression fires, the optional hook (script or http, same shape as session hooks) is executed first; its output must be JSON. The task prompt is then rendered as a Go template with the hook's JSON data and sent to the agent as the user message to run the scheduled task.

type MCPServer

type MCPServer struct {
	Type string `yaml:"type"`
	// for stdio
	Cmd  string            `yaml:"cmd,omitempty"`
	Args []string          `yaml:"args,omitempty"`
	Env  map[string]string `yaml:"env,omitempty"`
	// for sse & streamable-http
	URL               string            `yaml:"url,omitempty"`
	Headers           map[string]string `yaml:"headers,omitempty"`
	AutoApproval      bool              `yaml:"autoApproval"`
	AutoApprovalTools []string          `yaml:"autoApprovalTools"`
	// Tool filtering: include only these tools (if non-empty, only these tools are kept)
	Include []string `yaml:"include,omitempty"`
	// Tool filtering: exclude these tools (if non-empty, these tools are removed)
	Exclude []string `yaml:"exclude,omitempty"`
	// NoConcurrent: if true, all tools from this server share a single mutex,
	// meaning no two tools from this server can run concurrently.
	NoConcurrent bool `yaml:"noConcurrent,omitempty"`
	// NoConcurrentTools: list of specific tool names that should NOT be called concurrently.
	// Each listed tool gets its own mutex, so different tools don't block each other.
	NoConcurrentTools []string `yaml:"noConcurrentTools,omitempty"`
	// LowercaseTools: if true, all discovered tool names are lowercased before
	// filtering (include/exclude/autoApprovalTools/noConcurrentTools) and registration.
	LowercaseTools bool `yaml:"lowercaseTools,omitempty"`
}

MCPServer represents MCP server configuration

type MixedModel added in v1.5.2

type MixedModel struct {
	ModelParams `yaml:",inline"`
	Weight      int `yaml:"weight,omitempty"` // weight for weighted random selection (default: 1)
}

MixedModel represents a model entry within a mixed model configuration

type Model

type Model struct {
	ModelParams `yaml:",inline"`
	Mixed       []MixedModel `yaml:"mixed,omitempty"`
}

Model represents AI model configuration

func (Model) ContextSize added in v1.8.1

func (m Model) ContextSize() int

ContextSize returns the context window size in tokens declared by this model configuration. It is used as a fallback for a chat's maxContextTokens (window mode) when the chat does not set its own value. For a mixed model the smallest configured window across the entries (and the top-level params) is returned, so window-mode overflow is handled conservatively for every candidate model. Returns 0 when no context size is configured anywhere.

type ModelParams added in v1.5.2

type ModelParams struct {
	Provider         string         `yaml:"provider"`
	Model            string         `yaml:"model"`
	Thinking         bool           `yaml:"thinking"`
	ReasoningEffort  *string        `yaml:"reasoningEffort"`
	MaxTokens        int            `yaml:"maxTokens,omitempty"`
	MaxContextTokens int            `yaml:"maxContextTokens,omitempty"` // model context window size in tokens (fallback for window mode)
	Temperature      float64        `yaml:"temperature,omitempty"`
	TopP             float64        `yaml:"topP,omitempty"`
	TopK             int            `yaml:"topK,omitempty"`
	ExtraBody        map[string]any `yaml:"extraBody"`
}

ModelParams holds the common parameters for a model configuration. It is used both as the top-level Model and as entries inside Mixed.

type Provider

type Provider struct {
	Type    string            `yaml:"type"`
	BaseURL string            `yaml:"baseUrl,omitempty"`
	APIKey  string            `yaml:"apiKey,omitempty"`
	Headers map[string]string `yaml:"headers,omitempty"`
	Timeout int               `yaml:"timeout,omitempty"` // request timeout in seconds
	// IdleTimeout is the connection pool idle timeout in seconds for the
	// shared HTTP client. Default is 30 seconds.
	IdleTimeout int `yaml:"idleTimeout,omitempty"`
}

Provider represents AI provider configuration

type SessionHookConfig

type SessionHookConfig struct {
	Enabled    bool              `yaml:"enabled"`
	Type       string            `yaml:"type,omitempty"`    // "script" or "http", default is "script"
	ScriptPath string            `yaml:"scriptPath"`        // used when type is "script"
	URL        string            `yaml:"url,omitempty"`     // used when type is "http"
	Method     string            `yaml:"method,omitempty"`  // HTTP method for http type, default is "POST"
	Headers    map[string]string `yaml:"headers,omitempty"` // HTTP headers for http type
	Args       []string          `yaml:"args,omitempty"`
	Timeout    int               `yaml:"timeout,omitempty"` // in seconds, default is 30
	Env        map[string]string `yaml:"env,omitempty"`     // environment variables for the hook script
}

SessionHookConfig represents the configuration for a single hook

type SessionHooks

type SessionHooks struct {
	Keep          *SessionHookConfig `yaml:"keep,omitempty"`
	GenModelInput *SessionHookConfig `yaml:"genModelInput,omitempty"`
}

SessionHooks represents session-related hooks configuration

type Skill

type Skill struct {
	Dir               string   `yaml:"dir"`
	WorkDir           string   `yaml:"workDir"`
	Timeout           int      `yaml:"timeout"`
	AutoApproval      bool     `yaml:"autoApproval"`
	AutoApprovalTools []string `yaml:"autoApprovalTools"`
}

type Tool

type Tool struct {
	Category          string                 `yaml:"category"`
	Params            map[string]interface{} `yaml:"params"`
	AutoApproval      bool                   `yaml:"autoApproval"`
	AutoApprovalTools []string               `yaml:"autoApprovalTools"`
}

Jump to

Keyboard shortcuts

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