api

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleSystem    = "system"
	RoleAssistant = "assistant"
	RoleUser      = "user"
	RoleTool      = "tool"
)
View Source
const (
	ToolTypeFunc   = "func"
	ToolTypeSystem = "system"
	ToolTypeWeb    = "web"
	ToolTypeMcp    = "mcp"
	ToolTypeFaas   = "faas"
	ToolTypeAgent  = "agent"
)
View Source
const (
	VarsEnvContainer = "container"
	VarsEnvHost      = "host"
)
View Source
const (
	ContentTypeImageB64 = "img/base64"
)

Variables

View Source
var Levels = []Level{L1, L2, L3, Image, TTS}

Functions

func LogLevelToString added in v0.1.1

func LogLevelToString(level LogLevel) string

func NewBadRequestError added in v0.1.1

func NewBadRequestError(msg string) error

func NewInternalServerError added in v0.1.1

func NewInternalServerError(msg string) error

func NewNotFoundError added in v0.1.1

func NewNotFoundError(msg string) error

func NewUnauthorizedError added in v0.1.1

func NewUnauthorizedError(msg string) error

func NewUnsupportedError added in v0.1.1

func NewUnsupportedError(msg string) error

Types

type ATMSupport added in v0.1.1

type ATMSupport interface {
	AssetStore
	RetrieveAgent(owner, pack string) (*Record, error)
	ListAgents(owner string) ([]*Record, error)
	SearchAgent(owner, pack string) (*Record, error)
	RetrieveTool(owner, kit string) (*Record, error)
	ListTools(owner string) ([]*Record, error)
	RetrieveModel(owner, alias string) (*Record, error)
	ListModels(owner string) ([]*Record, error)
}

agent/tool/model methods

type Action added in v0.1.1

type Action struct {
	Tool *ToolFunc
}

type Agent

type Agent struct {
	Owner string

	// The name of the agent.
	Name        string
	Display     string
	Description string

	// system prompt
	Instruction *Instruction
	// user query
	Message string

	RawInput *UserInput

	// The model to be used by the agent
	Model *Model
	// Functions that the agent can call
	Tools []*ToolFunc

	Arguments map[string]any

	// LLM adapter
	Adapter string

	//
	Format string

	MaxTurns int
	MaxTime  int

	New        bool
	MaxHistory int
	MaxSpan    int
	Context    string

	LogLevel LogLevel

	//
	Flow *Flow

	//
	Embed []*Agent
}

func (*Agent) Clone added in v0.5.0

func (a *Agent) Clone() *Agent

type AgentConfig

type AgentConfig struct {
	Name        string `yaml:"name"`
	Display     string `yaml:"display"`
	Description string `yaml:"description"`

	//
	Instruction *Instruction `yaml:"instruction"`

	// set/level
	Model string `yaml:"model"`

	// tools defined in tools config
	// kit:name
	Functions []string `yaml:"functions"`

	Flow *FlowConfig `yaml:"flow"`

	// chat|image|docker/aider oh gptr
	Adapter string `yaml:"adapter"`

	//
	MaxTurns int `yaml:"max_turns"`
	MaxTime  int `yaml:"max_time"`

	// user message
	Message string `yaml:"message"`

	// output format: json | text
	Format string `yaml:"format"`

	// memory
	// max history: 0 max span: 0
	New        *bool  `yaml:"new,omitempty"`
	MaxHistory int    `yaml:"max_history"`
	MaxSpan    int    `yaml:"max_span"`
	Context    string `yaml:"context"`

	// logging: quiet | info[rmative] | verbose | trace
	LogLevel string `yaml:"log_level"`

	// agent as tool
	Parameters map[string]any `yaml:"parameters"`

	// default values for parameters
	Arguments map[string]any `yaml:"arguments"`

	// security
	Filters []*IOFilter  `yaml:"filters"`
	Guards  []*ToolGuard `yaml:"guards"`

	// inherit agents
	// message/instruction/tools
	Embed []string `yaml:"embed"`

	//
	Store AssetStore `yaml:"-"`
	// relative to root
	BaseDir string `yaml:"-"`
}

type AgentName added in v0.5.0

type AgentName string

[@][owner:]pack[/sub] @[owner:]<agent> agent: pack[/sub] @any @*

func (AgentName) Decode added in v0.5.0

func (a AgentName) Decode() (owner, pack, sub string)

[@][owner:]pack[/sub]

func (AgentName) Equal added in v0.5.0

func (a AgentName) Equal(s string) bool

func (AgentName) String added in v0.5.0

func (a AgentName) String() string

type AgentsConfig

type AgentsConfig struct {
	// agent app name
	Name string `yaml:"name"`

	// set/level key - not the LLM model
	Model string `yaml:"model"`

	Agents []*AgentConfig `yaml:"agents"`

	//
	MaxTurns int `yaml:"max_turns"`
	MaxTime  int `yaml:"max_time"`

	// user message
	Message string `yaml:"message"`

	// output format: json | text
	Format string `yaml:"format"`

	// memory
	// max history: 0 max span: 0
	New        *bool  `yaml:"new,omitempty"`
	MaxHistory int    `yaml:"max_history"`
	MaxSpan    int    `yaml:"max_span"`
	Context    string `yaml:"context"`

	// logging: quiet | informative | verbose
	LogLevel string `yaml:"log_level"`

	// toolkit
	// kit:any
	Kit   string        `yaml:"kit"`
	Type  string        `yaml:"type"`
	Tools []*ToolConfig `yaml:"tools"`

	// model set
	// set/any
	Set    string                  `yaml:"set"`
	Models map[string]*ModelConfig `yaml:"models"`

	// TODO separate?
	// model/tool shared default values
	Provider string `yaml:"provider"`
	BaseUrl  string `yaml:"base_url"`
	// api lookup key
	ApiKey string `yaml:"api_key"`
}

agent app config

type App added in v0.1.1

type App struct {
	// root agent
	Agent *Agent

	// user
	User *User

	// chat id to continue the conersation
	// <config_base>/chat/<id>.json
	ChatID string

	// history @agent
	Context    string
	MaxHistory int
	MaxSpan    int

	MaxTime  int
	MaxTurns int

	Models string

	//
	LogLevel string

	Unsafe bool

	//
	Workspace string

	//
	Stdin  string
	Stdout string
	Stderr string

	//
	Config *AppConfig
}

per session values for AppConfig

type AppConfig

type AppConfig struct {
	Version string

	ConfigFile string

	Agent string
	// Command string
	Args []string

	// --message takes precedence, skip stdin
	// command line arguments
	Message string

	// editor binary and args. e.g vim [options]
	Editor string

	Clipin   bool
	ClipWait bool

	Clipout    bool
	ClipAppend bool

	// IsPiped bool
	Stdin bool

	// Output format: raw or markdown
	Format string

	// user
	User *User

	// chat id to continue the conersation
	// <config_base>/chat/<id>.json
	ChatID string

	// conversation history
	New        *bool
	MaxHistory int
	MaxSpan    int

	// history @agent
	Context string

	Models string

	//
	LogLevel string

	Unsafe bool

	//
	Base string

	Workspace string

	Interactive bool
	Editing     bool
	Shell       string

	Watch     bool
	ClipWatch bool

	MaxTime  int
	MaxTurns int

	//
	Stdout string
	Stderr string

	// dry run
	DryRun        bool
	DryRunContent string
}

func (*AppConfig) Clone

func (cfg *AppConfig) Clone() *AppConfig

Clone is a shallow copy of member fields of the configration

func (*AppConfig) HasInput

func (r *AppConfig) HasInput() bool

func (*AppConfig) IsClipin

func (r *AppConfig) IsClipin() bool

func (*AppConfig) IsInformative added in v0.1.1

func (cfg *AppConfig) IsInformative() bool

func (*AppConfig) IsNew added in v0.5.1

func (cfg *AppConfig) IsNew() bool

func (*AppConfig) IsQuiet added in v0.1.1

func (cfg *AppConfig) IsQuiet() bool

func (*AppConfig) IsSpecial

func (r *AppConfig) IsSpecial() bool

func (*AppConfig) IsStdin

func (r *AppConfig) IsStdin() bool

func (*AppConfig) IsTracing added in v0.1.1

func (cfg *AppConfig) IsTracing() bool

func (*AppConfig) IsVerbose added in v0.1.1

func (cfg *AppConfig) IsVerbose() bool

type AssetFS added in v0.1.1

type AssetFS interface {
	AssetStore
	ReadDir(name string) ([]DirEntry, error)
	ReadFile(name string) ([]byte, error)
	Resolve(parent string, name string) string
}

type AssetManager added in v0.1.1

type AssetManager interface {
	// GetStore(key string) (AssetStore, error)
	AddStore(store AssetStore)

	SearchAgent(owner, pack string) (*Record, error)
	ListAgent(owner string) (map[string]*AgentsConfig, error)
	FindAgent(owner, pack string) (*AgentsConfig, error)
	ListToolkit(owner string) (map[string]*ToolsConfig, error)
	FindToolkit(owner string, kit string) (*ToolsConfig, error)
	ListModels(owner string) (map[string]*ModelsConfig, error)
	FindModels(owner string, alias string) (*ModelsConfig, error)
}

type AssetStore

type AssetStore any

type BadRequestError added in v0.1.1

type BadRequestError struct {
	Message string
}

func (*BadRequestError) Error added in v0.1.1

func (e *BadRequestError) Error() string

type Blob added in v0.1.1

type Blob struct {
	ID       string         `json:"id"`
	MimeType string         `json:"mime_type"`
	Content  []byte         `json:"content"`
	Meta     map[string]any `json:"meta"`
}

https://en.wikipedia.org/wiki/Media_type https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types https://mimesniff.spec.whatwg.org/

type BlobStore added in v0.1.1

type BlobStore interface {
	Put(ID string, blob *Blob) error
	Get(ID string) (*Blob, error)
	Presign(ID string) (string, error)
}

Object store

type Chat

type Chat struct {
	// uuid
	ID      string    `json:"id"`
	UserID  string    `json:"userId"`
	Created time.Time `json:"created"`

	// data
	Title string `json:"title"`
}

type ClipboardProvider

type ClipboardProvider interface {
	Clear() error
	Read() (string, error)
	Get() (string, error)
	Write(string) error
	Append(string) error
}

type ConnectorConfig added in v0.0.2

type ConnectorConfig struct {

	// optional as of now
	Provider string `yaml:"provider"`

	BaseUrl string `yaml:"base_url"`
	// name of api lookup key
	ApiKey string `yaml:"api_key"`
}

type ContextKey added in v0.1.1

type ContextKey string
const SwarmUserContextKey ContextKey = "swarm_user"

type DirEntry

type DirEntry = fs.DirEntry

Resource Store

func NewDirEntry

func NewDirEntry(
	name string,
	isDir bool,
	mode uint32,
	info *FileInfo,
) DirEntry

type DirEntryInfo

type DirEntryInfo struct {
	// contains filtered or unexported fields
}

func FsDirEntryInfo

func FsDirEntryInfo(de fs.DirEntry) *DirEntryInfo

func (*DirEntryInfo) Info

func (r *DirEntryInfo) Info() (fs.FileInfo, error)

func (*DirEntryInfo) IsDir

func (r *DirEntryInfo) IsDir() bool

func (DirEntryInfo) MarshalJSON

func (r DirEntryInfo) MarshalJSON() ([]byte, error)

func (*DirEntryInfo) Name

func (r *DirEntryInfo) Name() string

func (*DirEntryInfo) Type

func (r *DirEntryInfo) Type() fs.FileMode

func (*DirEntryInfo) UnmarshalJSON

func (r *DirEntryInfo) UnmarshalJSON(data []byte) error

type EditorProvider

type EditorProvider interface {
	Launch(string) (string, error)
}

type FileInfo

type FileInfo struct {
	// contains filtered or unexported fields
}

func FsFileInfo

func FsFileInfo(fi fs.FileInfo) *FileInfo

func NewFileInfo

func NewFileInfo(
	name string,
	size int64,
	mode uint32,
	modTime time.Time,
	isDir bool,
) *FileInfo

func (*FileInfo) IsDir

func (r *FileInfo) IsDir() bool

func (FileInfo) MarshalJSON

func (fi FileInfo) MarshalJSON() ([]byte, error)

func (*FileInfo) ModTime

func (r *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (r *FileInfo) Mode() fs.FileMode

func (*FileInfo) Name

func (r *FileInfo) Name() string

func (*FileInfo) Size

func (r *FileInfo) Size() int64

func (*FileInfo) Sys

func (r *FileInfo) Sys() any

func (*FileInfo) UnmarshalJSON

func (fi *FileInfo) UnmarshalJSON(data []byte) error

type Flow added in v0.9.0

type Flow struct {
	Type        FlowType
	Expression  string
	Concurrency int
	Retry       int
	Actions     []*Action
}

type FlowConfig added in v0.9.0

type FlowConfig struct {
	Type FlowType `yaml:"type"`

	// go template syntax
	Expression  string   `yaml:"expression"`
	Concurrency int      `yaml:"concurrency"`
	Retry       int      `yaml:"retry"`
	Actions     []string `yaml:"actions"`
}

type FlowType added in v0.1.1

type FlowType string
const (
	// actions are executed sequentially
	FlowTypeSequence FlowType = "sequence"
	// actions are executed in parallel and the final result will be a list
	FlowTypeParallel FlowType = "parallel"
	// action(s) are executed in a loop with a counter or expression evaluated for each cycle
	FlowTypeLoop FlowType = "loop"
	// one of the actions is selected based on an expression or randomly if no expression is provided
	// expression must evaluate to an integer (zero based).
	FlowTypeChoice FlowType = "choice"
	// The map flow creates a new array populated with the results of calling the action(s)
	// on every element in the input array
	FlowTypeMap FlowType = "map"
	// The reduce flow executes the action(s) on each element of the array, in order,
	// passing in the return value from the calculation on the preceding element.
	// The final result of running the reducer across all elements of the array is returned as a single value.
	// The first time that the flow is run, an initial value is read from the result of the previous agent
	// or empty if the flow is the root agent.
	FlowTypeReduce FlowType = "reduce"
	//
	FlowTypeNest FlowType = "nest"
)

type FuncBody added in v0.1.1

type FuncBody struct {
	Language string `yaml:"language"`
	Code     string `yaml:"code"`
	Url      string `yaml:"url"`
}

type Handler added in v0.1.0

type Handler interface {
	Serve(*Request, *Response) error
}

Agent handler

type IOFilter added in v0.5.0

type IOFilter struct {
	Agent string
}

type Instruction added in v0.0.6

type Instruction struct {
	// prefix supported: file: resource:
	// #! [--mime-type=text/x-go-template]
	Content string `yaml:"content"`

	// content type
	// text/x-go-template
	Type string `yaml:"type"`
}

type InternalServerError added in v0.1.1

type InternalServerError struct {
	Message string
}

func (*InternalServerError) Error added in v0.1.1

func (e *InternalServerError) Error() string

type KitName added in v0.5.0

type KitName string

func (KitName) Decode added in v0.5.0

func (r KitName) Decode() (string, string)

kit__name kit:* kit:name agent:name @name @:name

func (KitName) String added in v0.5.0

func (r KitName) String() string

type Level added in v0.0.3

type Level = string

Level represents the "intelligence" level of the model. i.e. basic, regular, advanced for example, OpenAI: gpt-4.1-mini, gpt-4.1, o3

const (
	// any of L1/L2/L3
	Any Level = "any"

	L1 Level = "L1"
	L2 Level = "L2"
	L3 Level = "L3"
	//
	Image Level = "image"
	TTS   Level = "tts"
)

type LogLevel added in v0.1.1

type LogLevel int
const (
	Quiet LogLevel = iota + 1
	Informative
	Verbose
	Tracing
)

func ToLogLevel added in v0.1.1

func ToLogLevel(level string) LogLevel

func (LogLevel) String added in v0.1.1

func (r LogLevel) String() string

type MemOption added in v0.0.3

type MemOption struct {
	MaxHistory int
	MaxSpan    int
}

Memory store

type MemStore added in v0.0.3

type MemStore interface {
	Save([]*Message) error
	Load(*MemOption) ([]*Message, error)
	Get(string) (*Message, error)
}

type Message

type Message struct {
	// message id
	ID string `json:"id"`

	// thread id
	ChatID  string    `json:"chat_id"`
	Created time.Time `json:"created"`

	// data
	ContentType string `json:"content_type"`
	Content     string `json:"content"`

	// system | assistant | user
	Role string `json:"role"`

	// user/agent
	Sender string `json:"sender"`
}

type Model

type Model struct {
	// model @agent or resolved provider model name
	// example:
	//   @model
	//   gemini-2.0-flash-lite
	Model string `json:"model"`

	Provider string `json:"provider"`
	BaseUrl  string `json:"base_url"`

	// api token lookup key
	ApiKey string `json:"api_key"`
}

func (*Model) String added in v0.1.1

func (r *Model) String() string

type ModelConfig

type ModelConfig struct {
	// LLM model
	Model string `yaml:"model"`

	// LLM service provider: openai | gemini | anthropic
	Provider string `yaml:"provider"`
	BaseUrl  string `yaml:"base_url"`
	// name of api key
	ApiKey string `yaml:"api_key"`
}

type ModelsConfig added in v0.0.3

type ModelsConfig struct {
	// model set name
	Set string `yaml:"set"`

	// provider
	Provider string `yaml:"provider"`
	BaseUrl  string `yaml:"base_url"`
	// name of api lookup key - never the actual api token
	ApiKey string `yaml:"api_key"`

	Models map[string]*ModelConfig `yaml:"models"`
}

type NotFoundError added in v0.1.1

type NotFoundError struct {
	Message string
}

func (*NotFoundError) Error added in v0.1.1

func (e *NotFoundError) Error() string

type Output

type Output struct {
	// Agent icon and name
	Display string `json:"display"`

	Content     string `json:"content"`
	ContentType string `json:"content_type"`
}

type Record added in v0.1.1

type Record struct {
	ID uuid.UUID

	Owner   string
	Name    string
	Display string
	Content string

	// source
	Store AssetStore
}

type Request

type Request struct {
	// parent agent
	Parent *Agent

	// The name of the active agent/tool
	Name      string
	Arguments map[string]any

	Messages []*Message

	RawInput *UserInput
	// contains filtered or unexported fields
}

func NewRequest added in v0.1.1

func NewRequest(ctx context.Context, name string, input *UserInput) *Request

func (*Request) Clone

func (r *Request) Clone() *Request

Clone returns a shallow copy of r while ensuring proper copying of slices and maps

func (*Request) Context

func (r *Request) Context() context.Context

Context returns the request's context. To change the context, use Request.WithContext.

The returned context is always non-nil; it defaults to the background context.

For outgoing client requests, the context controls cancellation.

For incoming server requests, the context is canceled when the client's connection closes, the request is canceled (with HTTP/2), or when the ServeHTTP method returns.

func (*Request) WithContext

func (r *Request) WithContext(ctx context.Context) *Request

WithContext returns a shallow copy of r with its context changed to ctx. The provided ctx must be non-nil.

For outgoing client request, the context controls the entire lifetime of a request and its response: obtaining a connection, sending the request, and reading the response headers and body.

To create a new request with a context, use NewRequest. To make a deep copy of a request with a new context, use Request.Clone.

type Resource

type Resource struct {
	// web resource base url
	// http://localhost:18080/resource
	// https://ai.dhnt.io/resource
	Base string `json:"base"`

	// access token
	Token string `json:"token"`
}

type ResourceConfig added in v0.1.1

type ResourceConfig struct {
	Base  string `json:"base"`
	Token string `json:"token"`
}

func LoadResourceConfig added in v0.9.0

func LoadResourceConfig(conf string) (*ResourceConfig, error)

type Response

type Response struct {
	// A list of message objects generated during the conversation
	// with a sender field indicating which Agent the message originated from.
	Messages []*Message

	// The last agent to handle a message
	Agent *Agent

	Result *Result
}

type Result

type Result struct {
	// The result value as a string
	Value string

	// media content
	// https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types
	MimeType string
	Content  []byte

	// transition
	// The agent state
	State State
	// The agent name to transfer to for StateTransfer
	NextAgent string
}

Result encapsulates the possible return values for agent/function.

func (*Result) String

func (r *Result) String() string

type SecretStore added in v0.1.1

type SecretStore interface {
	Get(owner, key string) (string, error)
}

type State

type State int
const (
	StateDefault State = iota

	StateExit
	StateTransfer
	StateInputWait
)

func ParseState

func ParseState(s string) State

func (State) Equal

func (r State) Equal(s string) bool

func (State) String

func (r State) String() string

type TemplateFuncMap

type TemplateFuncMap = template.FuncMap

type ToolCondition

type ToolCondition struct {
	// required env list
	Env []string `yaml:"env"`

	// found on PATH
	Lookup *string `yaml:"lookup"`

	// shell required
	Shell map[string]any `yaml:"shell"`
}

TODO condidtion needs to be met for tools to be enabled

type ToolConfig

type ToolConfig struct {
	Type string `yaml:"type"`

	Name string `yaml:"name"`

	Description string         `yaml:"description"`
	Parameters  map[string]any `yaml:"parameters"`

	Body *FuncBody `yaml:"body"`

	Condition *ToolCondition `yaml:"condition"`

	// agent name for agent tool type
	// description/parameters defined here take precedence
	Agent string `yaml:"agent"`

	//
	Provider string `yaml:"provider"`
	BaseUrl  string `yaml:"base_url"`
	// name of api key
	ApiKey string `yaml:"api_key"`

	// filter by match key=values (comma, separated)
	// include all tools that match
	Filter map[string]string `yaml:"filter"`
}

type ToolEnv added in v0.9.0

type ToolEnv struct {
	// User  string
	Owner string
}

per tool call vars

type ToolFunc

type ToolFunc struct {
	Type string

	Kit         string
	Name        string
	Description string
	Parameters  map[string]any

	Body *FuncBody

	// agent name if this tool references an agent
	Agent string

	//
	State State

	//
	Provider string
	BaseUrl  string
	// name of api key - used to resolve api key/token before tool call
	ApiKey string

	Extra map[string]any
}

func (*ToolFunc) ID

func (r *ToolFunc) ID() string

ID returns a unique identifier for the tool, combining the tool kit and name. A string that must match the pattern '^[a-zA-Z0-9_-]+$'."

type ToolGuard added in v0.1.1

type ToolGuard struct {
	Agent string
}

type ToolKit added in v0.1.1

type ToolKit interface {
	Call(context.Context, *Vars, *ToolEnv, *ToolFunc, map[string]any) (any, error)
}

type ToolRunner added in v0.5.0

type ToolRunner func(context.Context, string, map[string]any) (*Result, error)

type ToolSystem added in v0.0.2

type ToolSystem interface {
	GetKit(key any) (ToolKit, error)
	AddKit(key any, kit ToolKit)
}

type ToolsConfig

type ToolsConfig struct {
	// kit name specifies a namespace.
	// e.g. but not limited to:
	// class name
	// MCP server name
	// virtual filesystem name
	// container name
	// virtual machine name
	// tool/function (Gemini)
	Kit string `yaml:"kit"`

	// func (server) | system (client) | remote
	Type string `yaml:"type"`

	// provider
	Provider string `yaml:"provider"`
	BaseUrl  string `yaml:"base_url"`
	// name of api key
	ApiKey string `yaml:"api_key"`

	// system commands used by tools
	Commands []string `yaml:"commands"`

	Tools []*ToolConfig `yaml:"tools"`
}

Toolkit configuration

type UnauthorizedError added in v0.1.1

type UnauthorizedError struct {
	Message string
}

func (*UnauthorizedError) Error added in v0.1.1

func (e *UnauthorizedError) Error() string

type UnsupportedError added in v0.1.1

type UnsupportedError struct {
	Message string
}

func (*UnsupportedError) Error added in v0.1.1

func (e *UnsupportedError) Error() string

type User

type User struct {
	// uuid
	ID string `json:"id"`

	//
	// Username string `json:"username"`
	// emoji + nickname
	Display string `json:"display"`

	Email string `json:"email"`
	// full/first,last
	Name   string `json:"name"`
	Avatar string `json:"avatar"`
}

type UserInput

type UserInput struct {

	// query - command line args
	Message string `json:"message"`

	// query - clipboard/stdin/editor
	Content string `json:"content"`

	// cached media contents
	Messages []*Message `json:"-"`
}

func (*UserInput) Clone added in v0.4.0

func (r *UserInput) Clone() *UserInput

func (*UserInput) Intent

func (r *UserInput) Intent() string

Intent returns a clipped version of the query. This is intended for "smart" agents to make decisions based on user inputs.

func (*UserInput) IsEmpty

func (r *UserInput) IsEmpty() bool

No user input.

func (*UserInput) Query

func (r *UserInput) Query() string

Text input from command line args, clipboard, stdin, or editor

func (*UserInput) String

func (r *UserInput) String() string

type Vars

type Vars struct {
	LogLevel LogLevel `json:"log_level"`

	ChatID     string `json:"chat_id"`
	MaxTurns   int    `json:"max_turns"`
	MaxTime    int    `json:"max_time"`
	New        *bool  `json:"new"`
	MaxHistory int    `json:"max_history"`
	MaxSpan    int    `json:"max_span"`
	Context    string `json:"context"`
	Format     string `json:"format"`
	Models     string `json:"models"`

	Unsafe    bool   `json:"unsafe"`
	Workspace string `json:"workspace"`

	DryRun        bool   `json:"-"`
	DryRunContent string `json:"-"`

	// conversation history
	History []*Message     `json:"-"`
	Global  map[string]any `json:"-"`
}

global context

func NewVars

func NewVars() *Vars

func (*Vars) Clone added in v0.5.0

func (v *Vars) Clone() *Vars

func (*Vars) Get

func (r *Vars) Get(key string) any

func (*Vars) GetString

func (r *Vars) GetString(key string) string

func (*Vars) IsTrace added in v0.7.0

func (r *Vars) IsTrace() bool

Jump to

Keyboard shortcuts

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