Documentation
¶
Index ¶
- Constants
- func FindLastChatID(base string) (string, error)
- func StoreHistory(base string, messages []*Message) error
- type Advice
- type AdviceConfig
- type Agent
- type AgentConfig
- type AgentResource
- type Agentic
- type AgentsConfig
- type AppConfig
- type AssetStore
- type Chat
- type ClipboardProvider
- type ConnectorConfig
- type DBCred
- type DirEntry
- type DirEntryInfo
- type EditorProvider
- type Entrypoint
- type FileInfo
- func (r *FileInfo) IsDir() bool
- func (fi FileInfo) MarshalJSON() ([]byte, error)
- func (r *FileInfo) ModTime() time.Time
- func (r *FileInfo) Mode() fs.FileMode
- func (r *FileInfo) Name() string
- func (r *FileInfo) Size() int64
- func (r *FileInfo) Sys() any
- func (fi *FileInfo) UnmarshalJSON(data []byte) error
- type Function
- type FunctionConfig
- type GitConfig
- type HubConfig
- type InstructionConfig
- type LLMConfig
- type LLMRequest
- type LLMResponse
- type Message
- type Model
- type ModelConfig
- type Output
- type Request
- type Resource
- type Response
- type ResponseWriter
- type Result
- type State
- type TTSConfig
- type TemplateFuncMap
- type ToolCondition
- type ToolConfig
- type ToolDescriptor
- type ToolFunc
- type ToolSystem
- type ToolsConfig
- type User
- type UserInput
- type Vars
Constants ¶
const ( RoleSystem = "system" RoleAssistant = "assistant" RoleUser = "user" RoleTool = "tool" )
const ( ContentTypeText = "text" ContentTypeB64JSON = string(openai.ImageGenerateParamsResponseFormatB64JSON) )
const ( VarsEnvContainer = "container" VarsEnvHost = "host" )
Variables ¶
This section is empty.
Functions ¶
func FindLastChatID ¶
func StoreHistory ¶
Types ¶
type AdviceConfig ¶
type Agent ¶
type Agent struct {
Adapter string
// The name of the agent.
Name string
Display string
// The model to be used by the agent
Model string
// The role of the agent. default is "system"
Role string
RawInput *UserInput
// Functions that the agent can call
Tools []*ToolFunc
Entrypoint Entrypoint
Dependencies []string
// advices
BeforeAdvice Advice
AfterAdvice Advice
AroundAdvice Advice
//
MaxTurns int
MaxTime int
Config *AgentConfig
}
type AgentConfig ¶
type AgentConfig struct {
Name string `yaml:"name"`
Display string `yaml:"display"`
Description string `yaml:"description"`
//
Instruction *InstructionConfig `yaml:"instruction"`
Model string `yaml:"model"`
// model alias
Models string `yaml:"models"`
Entrypoint string `yaml:"entrypoint"`
Functions []string `yaml:"functions"`
Dependencies []string `yaml:"dependencies"`
Advices *AdviceConfig `yaml:"advices"`
// chat|image-get|docker/aider oh gptr
Adapter string `yaml:"adapter"`
//
Store AssetStore `yaml:"-"`
// relative to root
BaseDir string `yaml:"-"`
}
type AgentResource ¶
type AgentResource struct {
Resources []*Resource `json:"resources"`
}
func LoadAgentResource ¶
func LoadAgentResource(p string) (*AgentResource, error)
type AgentsConfig ¶
type AgentsConfig struct {
// agent group name
Name string `yaml:"name"`
Agents []*AgentConfig `yaml:"agents"`
Functions []*FunctionConfig `yaml:"functions"`
Models []*ModelConfig `yaml:"models"`
MaxTurns int `yaml:"maxTurns"`
MaxTime int `yaml:"maxTime"`
}
type AppConfig ¶
type AppConfig struct {
Version string
ConfigFile string
ModelLoader func(string) (*model.Model, error)
AgentResource *AgentResource
AgentLister func() map[string]*AgentsConfig
AgentLoader func(string) (*AgentsConfig, error)
ToolSystem ToolSystem
ToolLoader func(string) ([]*ToolFunc, error)
// ToolSystemCommands []string
SystemTools []*ToolFunc
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
Files []string
// Treated as file
Screenshot bool
// Treated as input text
Voice bool
// Output format: raw or markdown
Format string
// output file for saving response
Output string
Me *User
//
Template string
// conversation history
New bool
MaxHistory int
MaxSpan int
// chat id to continue the conersation
// <config_base>/chat/<id>.json
ChatID string
//<config_base>/chat/<id>/*.json
History []*Message
Models string
Log string
// TODO change to log level?
Trace bool
Debug bool
Quiet bool
DenyList []string
AllowList []string
Unsafe bool
//
Base string
Workspace string
// Repo string
Home string
Temp string
Interactive bool
Editing bool
Shell string
Watch bool
ClipWatch bool
Hub *HubConfig
MaxTime int
MaxTurns int
//
Stdout string
Stderr string
// dry run
DryRun bool
DryRunContent string
// experimental
// provider -> api-key
ApiKeys map[string]string
}
type AssetStore ¶
type ClipboardProvider ¶
type ConnectorConfig ¶ added in v0.0.2
type ConnectorConfig struct {
// mcp | ssh ...
Proto string `yaml:"proto"`
// ssh://user@example.com:2222/user/home
// git@github.com:owner/repo.git
// postgres://dbuser:secret@db.example.com:5432/mydb?sslmode=require
// https://drive.google.com/drive/folders
// mailto:someone@example.com
URL string `yaml:"url"`
}
type DBCred ¶
type DBCred struct {
Host string `mapstructure:"host"`
Port string `mapstructure:"port"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
DBName string `mapstructure:"name"`
}
type DirEntryInfo ¶
type DirEntryInfo struct {
// contains filtered or unexported fields
}
func FsDirEntryInfo ¶
func FsDirEntryInfo(de fs.DirEntry) *DirEntryInfo
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 FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
func FsFileInfo ¶
func NewFileInfo ¶
func (FileInfo) MarshalJSON ¶
func (*FileInfo) UnmarshalJSON ¶
type Function ¶
Swarm Agents can call functions directly. Function should usually return a string values. If a function returns an Agent, execution will be transferred to that Agent.
type FunctionConfig ¶
type InstructionConfig ¶
type LLMConfig ¶
type LLMRequest ¶
type LLMRequest struct {
Agent string
Model *Model
Messages []*Message
MaxTurns int
RunTool func(ctx context.Context, name string, props map[string]any) (*Result, error)
Tools []*ToolFunc
// Experimenal
Vars *Vars
}
func (*LLMRequest) String ¶
func (r *LLMRequest) String() string
type LLMResponse ¶
type Message ¶
type Message struct {
ID string `json:"id"`
ChatID string `json:"chatId"`
Created time.Time `json:"created"`
// data
ContentType string `json:"contentType"`
Content string `json:"content"`
Role string `json:"role"`
// agent name
Sender string `json:"sender"`
// model alias
Models string `json:"models"`
}
type ModelConfig ¶
type Request ¶
type Request struct {
// The name/command of the active agent
Agent string
Command string
Messages []*Message
RawInput *UserInput
// contains filtered or unexported fields
}
func (*Request) Clone ¶
Clone returns a shallow copy of r with its context changed to ctx. The provided ctx must be non-nil.
Clone only makes a shallow copy of the Body field.
For an 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.
func (*Request) Context ¶
Context returns the request's context. To change the context, use Request.Clone or 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 ¶
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 [NewRequestWithContext]. 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 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
}
func (*Response) LastMessage ¶
type ResponseWriter ¶
type Result ¶
type Result struct {
// The result value as a string
Value string
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types
MimeType string
Message string
// The agent state
State State
// The agent name to transfer to for StateTransfer
NextAgent string
}
Result encapsulates the possible return values for agent/function.
type TemplateFuncMap ¶
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 ToolDescriptor ¶
ToolDescriptor is a description of a tool function.
type ToolFunc ¶
type ToolFunc struct {
// Namespace:
//
// func class
// Agent name
// MCP server name
// Virtual file system name
// Container name
// Virtual machine name
// Tool/function (Gemini)
Kit string
// func | system | remote
Type string
State State
// func name
Name string
Description string
Parameters map[string]any
Body string
//
Config *ToolsConfig
}
type ToolSystem ¶ added in v0.0.2
type ToolsConfig ¶
type ToolsConfig struct {
// kit name
Kit string `yaml:"kit"`
// func (server) | system (client) | remote
Type string `yaml:"type"`
Connector *ConnectorConfig `yaml:"connector"`
// system commands used by tools
Commands []string `yaml:"commands"`
Tools []*ToolConfig `yaml:"tools"`
}
Kit configuration
type UserInput ¶
type UserInput struct {
Agent string `json:"agent"`
Command string `json:"command"`
// query - command line args
Message string `json:"message"`
// query - clipboard/stdin/editor
Content string `json:"content"`
// TODO deprecate
Template string `json:"template"`
Files []string `json:"files"`
Extra map[string]any `json:"extra"`
// cached file contents
Messages []*Message `json:"-"`
}
func (*UserInput) FileContent ¶
func (*UserInput) FileMessages ¶
func (*UserInput) Intent ¶
Intent returns a clipped version of the query. This is intended for "smart" agents to make decisions based on user inputs.
type Vars ¶
type Vars struct {
Config *AppConfig `json:"config"`
OS string `json:"os"`
Arch string `json:"arch"`
ShellInfo map[string]string `json:"shell_info"`
OSInfo map[string]string `json:"os_info"`
UserInfo map[string]string `json:"user_info"`
UserInput *UserInput `json:"user_input"`
Workspace string `json:"workspace"`
// Repo string `json:"repo"`
Home string `json:"home"`
Temp string `json:"temp"`
// EnvType indicates the environment type where the agent is running
// It can be "container" for Docker containers or "host" for the host machine
EnvType string `json:"env_type"`
Roots []string `json:"roots"`
//
Extra map[string]string `json:"extra"`
// conversation history
History []*Message
}
global context