agent

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TypeText            = "text"
	TypeImage           = "image"
	TypeVideo           = "video"
	RoleSystem          = "system"
	RoleUser            = "user"
	RoleAssistant       = "assistant"
	RoleTool            = "tool"
	ToolCodeInterpreter = "codeInterpreter"
	ToolWebSearch       = "webSearch"
)

Variables

This section is empty.

Functions

func RegisterAgentMaker

func RegisterAgentMaker(agentId string, maker func(APIConfig) Agent)

Types

type APIConfig

type APIConfig struct {
	Endpoint               string
	ApiKey                 string
	DefaultChatModelConfig ChatModelConfig
}

type Agent

type Agent interface {
	Support() Support
	Ask(messages []ChatMessage, config *ChatModelConfig, callback func(answer string)) (string, TokenUsage, error)
	FastAsk(messages []ChatMessage, callback func(answer string)) (string, TokenUsage, error)
	LongAsk(messages []ChatMessage, callback func(answer string)) (string, TokenUsage, error)
	BatterAsk(messages []ChatMessage, callback func(answer string)) (string, TokenUsage, error)
	BestAsk(messages []ChatMessage, callback func(answer string)) (string, TokenUsage, error)
	MultiAsk(messages []ChatMessage, callback func(answer string)) (string, TokenUsage, error)
	BestMultiAsk(messages []ChatMessage, callback func(answer string)) (string, TokenUsage, error)
	CodeInterpreterAsk(messages []ChatMessage, callback func(answer string)) (string, TokenUsage, error)
	WebSearchAsk(messages []ChatMessage, callback func(answer string)) (string, TokenUsage, error)
	MakeImage(model, prompt, size, refImage string) ([]string, error)
	FastMakeImage(prompt, size, refImage string) ([]string, error)
	BestMakeImage(prompt, size, refImage string) ([]string, error)
	MakeVideo(model, prompt, size, refImage string) ([]string, []string, error)
	FastMakeVideo(prompt, size, refImage string) ([]string, []string, error)
	BestMakeVideo(prompt, size, refImage string) ([]string, []string, error)
}

func CreateAgent

func CreateAgent(name, agentId string, config APIConfig) Agent

func GetAgent

func GetAgent(name string) Agent

type ChatMessage

type ChatMessage struct {
	Role     string
	Contents []ChatMessageContent
}

type ChatMessageContent

type ChatMessageContent struct {
	Type    string // text, image, audio, video
	Content string
}

type ChatModelConfig

type ChatModelConfig struct {
	Model       string
	Ratio       float64
	MaxTokens   int
	Temperature float64
	TopP        float64
	Tools       map[string]any
	// contains filtered or unexported fields
}

func (*ChatModelConfig) GetMaxTokens

func (cmc *ChatModelConfig) GetMaxTokens() int

func (*ChatModelConfig) GetModel

func (cmc *ChatModelConfig) GetModel() string

func (*ChatModelConfig) GetTemperature

func (cmc *ChatModelConfig) GetTemperature() float64

func (*ChatModelConfig) GetTools

func (cmc *ChatModelConfig) GetTools() map[string]any

func (*ChatModelConfig) GetTopP

func (cmc *ChatModelConfig) GetTopP() float64

func (*ChatModelConfig) SetDefault

func (cmc *ChatModelConfig) SetDefault(config *ChatModelConfig)

type Support

type Support struct {
	Ask                    bool
	AskWithImage           bool
	AskWithVideo           bool
	AskWithCodeInterpreter bool
	AskWithWebSearch       bool
	MakeImage              bool
	MakeVideo              bool
	Models                 []string
}

type TokenUsage

type TokenUsage struct {
	AskTokens    int64
	AnswerTokens int64
	TotalTokens  int64
}

Jump to

Keyboard shortcuts

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