Documentation ¶
Index ¶
- Constants
- func InitSQL(dsn string) error
- type Bot
- func (b *Bot) AddConversation(key string) error
- func (b *Bot) AddDefinitions(name string, definitions *map[string]openai.FunctionDefinition)
- func (b *Bot) AddHandlers(handlers ...func(function string, input *types.Input) any)
- func (b *Bot) AddMessage(key string, role string, name string, content string) error
- func (b *Bot) AddQueuedFunctions(funcs ...func(bot *Bot, input *types.Input) *types.Output)
- func (b *Bot) DeleteConversation(key string) error
- func (b *Bot) EditVariable(key string, value any)
- func (b *Bot) GetVariable(key string) any
- func (b *Bot) IsConversation(key string) bool
- func (b *Bot) SendMessage(key string, input *types.Input) (*types.Output, error)
- func (b *Bot) Setup(client *openai.Client)
- type Conversation
- func (c *Conversation) AddFunctionCall(message *openai.ChatCompletionMessage) error
- func (c *Conversation) AddMessage(role string, name string, content string) error
- func (c *Conversation) Delete() error
- func (c *Conversation) SendFunctionCalls() (*openai.ChatCompletionResponse, error)
- func (c *Conversation) SendMessage(role string, name string, content string) (*openai.ChatCompletionResponse, error)
- type Memory
- type Message
- type ToolCall
Constants ¶
const ( PERMISSIONS_NONE = 0b00000000 // Null value - nothing is enabled PERMISSIONS_GPT = 0b00000001 // GPT functionality is enabled PERMISSIONS_PRVMODULES = 0b00000010 // Only "private" custom modules are enabled PERMISSIONS_PUBMODULES = 0b00000100 // Only "public" custom modules are enabled PERMISSIONS_ALLMODULES = 0b00000110 // All custom modules are enabled PERMISSIONS_ALL = 0b11111111 // All custom modules and GPT functionality is enabled )
const ( OPENAI_MODEL = openai.GPT3Dot5Turbo // What OpenAI model is being used OPENAI_ROLE = openai.ChatMessageRoleSystem OPENAI_MAXTOKENS = 500 // What is the maximum amount of tokens that can be sent to the model? (Tokens = Words / 0.75) OPENAI_SYSPROMPT = `You are a helpful personal assistant named Horus.` // System Prompt for the OpenAI model )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bot ¶
type Bot struct { gorm.Model Name string // The name of the bot Permissions byte // A byte representation of allowed permissions Memory Memory // Static memory associated with a bot Conversations []Conversation // A list of conversations with the user // contains filtered or unexported fields }
Bot represents an implementation of Horus. It contains multiple conversations with a given user as well as defining characteristics
func GetAllBots ¶
GetAllBots gets a list of all bots in the SQL database
func GetBotByName ¶
GetBotByName gets a singular bot by name from the SQL database
func (*Bot) AddConversation ¶
AddConversation adds a new conversation to the bot
func (*Bot) AddDefinitions ¶
func (b *Bot) AddDefinitions(name string, definitions *map[string]openai.FunctionDefinition)
Adds definitions to the bot's function definitions
func (*Bot) AddHandlers ¶
Adds handlers to the bot's handlers
func (*Bot) AddMessage ¶
Add a message to a conversation
func (*Bot) AddQueuedFunctions ¶
Add a list of functions to the function queue
func (*Bot) DeleteConversation ¶
DeleteConversation delets a conversation from the bot
func (*Bot) EditVariable ¶
Writes a value to the variables map
func (*Bot) GetVariable ¶
Returns a value from the variables map
func (*Bot) IsConversation ¶
IsConversation returns true if the conversation exists
func (*Bot) SendMessage ¶
SendMessage sends a message to the bot in a given conversation
type Conversation ¶
type Conversation struct { gorm.Model BotID uint // The foreign key to relate the conversation to a bot Name string // A unique identifying key for the converesation Messages []Message // A list of messages in the conversation // contains filtered or unexported fields }
Conversation represents a conversation between Horus and the user
func (*Conversation) AddFunctionCall ¶
func (c *Conversation) AddFunctionCall(message *openai.ChatCompletionMessage) error
Add function call to the conversation
func (*Conversation) AddMessage ¶
func (c *Conversation) AddMessage(role string, name string, content string) error
Add a message to the conversation without sending it
func (*Conversation) Delete ¶
func (c *Conversation) Delete() error
Delete a conversation and all associated messages
func (*Conversation) SendFunctionCalls ¶
func (c *Conversation) SendFunctionCalls() (*openai.ChatCompletionResponse, error)
SendFunctionCalls gets a new response with added function calls
func (*Conversation) SendMessage ¶
func (c *Conversation) SendMessage(role string, name string, content string) (*openai.ChatCompletionResponse, error)
SendMessage sends a message to OpenAI
type Memory ¶
type Memory struct { gorm.Model BotID uint // The foreign key to relate the Memory struct to the Bot Timezone string City string TemperatureUnit string }
Memory represents a static memory bank used by a Bot. Values in this struct get stored to SQL and are saved past reboot
type Message ¶
type Message struct { gorm.Model ConversationID uint // The conversation this message is related to Idx uint // The index of the message in the conversation Role string // The role of the entity speaking the message Name string // The message's type Content string // The content of the message // Tools related to the message call ToolCallID string ToolCalls []ToolCall // The openAI message this message is representing ChatCompletionMessage *openai.ChatCompletionMessage `gorm:"-"` }
Message represents a sent message in a conversation
Directories ¶
Path | Synopsis |
---|---|
definitions.go contains all OpenAI function declarations
|
definitions.go contains all OpenAI function declarations |