api

package
v0.0.0-...-020849e Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeText    = "text"
	ContentTypeB64JSON = string(openai.ImageGenerateParamsResponseFormatB64JSON)
)

Variables

This section is empty.

Functions

This section is empty.

Types

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"`
}

func (*DBCred) DSN

func (d *DBCred) DSN() string

DSN returns the data source name for connecting to the database.

func (*DBCred) IsValid

func (d *DBCred) IsValid() bool

type LLMConfig

type LLMConfig struct {
	Model   string
	BaseUrl string
	ApiKey  string

	L1Model   string
	L1BaseUrl string
	L1ApiKey  string

	L2Model   string
	L2BaseUrl string
	L2ApiKey  string

	L3Model   string
	L3BaseUrl string
	L3ApiKey  string

	ImageModel   string
	ImageBaseUrl string
	ImageApiKey  string
}

func (*LLMConfig) Clone

func (cfg *LLMConfig) Clone() *LLMConfig

type Level

type Level int

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

const (
	L0 Level = iota
	L1
	L2
	L3
)

type Message

type Message struct {
	ContentType string
	Content     string

	Role   string
	Sender string
}

type Model

type Model struct {
	Type    ModelType
	Name    string
	BaseUrl string
	ApiKey  string
}

func CreateModel

func CreateModel(cfg *LLMConfig, opt ...Level) *Model

CreateModel creates a model with the given configuration and optional level

func ImageModel

func ImageModel(cfg *LLMConfig) *Model

func Level1

func Level1(cfg *LLMConfig) *Model

func Level2

func Level2(cfg *LLMConfig) *Model

func Level3

func Level3(cfg *LLMConfig) *Model

type ModelType

type ModelType string
const (
	ModelTypeUnknown ModelType = ""
	ModelTypeText    ModelType = "text"
	ModelTypeImage   ModelType = "image"
)

type Request

type Request struct {
	ModelType ModelType
	BaseUrl   string
	ApiKey    string
	Model     string

	// History  []*Message
	Messages []*Message

	MaxTurns int
	RunTool  func(ctx context.Context, name string, props map[string]any) (*Result, error)

	Tools []*ToolFunc
}

type Response

type Response struct {
	ContentType string
	Content     string

	Agent string
	Role  string

	Result *Result
}

type Result

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

	// The current agent instance
	State State

	// The agent name to transfer to for StateTransfer
	NextAgent string
}

Result encapsulates the possible return values for an agent function.

type State

type State int
const (
	StateUnknown State = iota

	StateExit
	StateTransfer
	StateInputWait
)

type ToolFunc

type ToolFunc struct {
	Name        string
	Description string
	Parameters  map[string]any
}

type UserInput

type UserInput struct {
	Agent      string `json:"agent"`
	Subcommand string `json:"subcommand"`

	Message string `json:"message"`
	Content string `json:"content"`

	Template string `json:"template"`

	Files []string `json:"files"`

	Extra map[string]any `json:"extra"`
}

func (*UserInput) FileContent

func (r *UserInput) FileContent() (string, error)

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

func (*UserInput) Query

func (r *UserInput) Query() string

Jump to

Keyboard shortcuts

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