Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultConfig ¶ added in v0.1.4
func NewDefaultConfig(apiProvider models.ApiProvider, apiToken, chatModel, embeddingModel string, vectorDbType models.VectorDbType, vectorDbUrl, vectorDbToken string) *models.Configuration
NewDefaultConfig creates a new default configuration with the provided API provider, API token, and model.
func ReadImageFromFile ¶
func ReadImageFromFile(filepath string) (models.Base64Image, error)
ReadImageFromFile reads an image from the specified filepath and returns a Base64 encoded image.
Types ¶
type AICompanion ¶
type AICompanion interface {
// PrepareConversation initializes a new conversation with a default system message
PrepareConversation() []models.Message
// CreateMessage creates a new message with the given role and input string
CreateMessage(role models.Role, input string) models.Message
// CreateMessageWithImages creates a new message with the given role, input string, and images
CreateMessageWithImages(role models.Role, message string, images *[]models.Base64Image) models.Message
//CreateUserMessage creates a new user message with the given input string
CreateUserMessage(input string, images *[]models.Base64Image) models.Message
// CreateAssistantMessage creates a new assistant message with the given input string
CreateAssistantMessage(input string) models.Message
// AddMessage adds a new message to the conversation
AddMessage(message models.Message)
// GetConfig returns the current configuration for the AI companion
GetConfig() models.Configuration
// SetConfig sets a new configuration for the AI companion
SetConfig(config models.Configuration)
// GetSystemRole returns the current system role message
GetSystemRole() models.Message
// SetSystemRole sets a new system role message
SetSystemRole(prompt string)
// GetEnrichmentPrompt returns the current enrichment prompt
GetEnrichmentPrompt() string
// SetEnrichmentPrompt sets a new enrichment prompt
SetEnrichmentPrompt(prompt string)
// GetFunctionsPrompt returns the current functions prompt
GetFunctionsPrompt() string
// SetFunctionsPrompt sets a functions prompt
SetFunctionsPrompt(prompt string)
// GetSummarizationPrompt returns the current summarization prompt
GetSummarizationPrompt() string
// SetSummarizationPrompt sets a summarization prompt
SetSummarizationPrompt(prompt string)
// GetConversation returns the current conversation
GetConversation() []models.Message
// SetConversation sets the current conversation
SetConversation(conversation []models.Message)
// GetClient returns the current HTTP client used for requests
GetClient() *http.Client
// SetClient sets a new HTTP client for requests
SetClient(client *http.Client)
// interactions
// GetModels returns all models that the endpoint supports
GetModels() ([]models.Model, error)
// SendChatRequest sends a chat request to an AI model and returns a response message
SendChatRequest(message models.Message, streaming bool, callback func(m models.Message) error) (models.Message, error)
// SendCompletionRequest sends a completion request to an AI model and returns a response message
SendGenerateRequest(message models.Message, streaming bool, callback func(m models.Message) error) (models.Message, error)
// SendEmbeddingRequest sends an embedding request to an AI model and returns a response
SendEmbeddingRequest(embedding models.EmbeddingRequest) (models.EmbeddingResponse, error)
// SendModerationRequest sends a moderation request to an AI model and returns a response
SendModerationRequest(moderationRequest models.ModerationRequest) (models.ModerationResponse, error)
HandleStreamResponse(resp *http.Response, streamType models.StreamType, callback func(m models.Message) error) (models.Message, error)
SetVectorDBClient(vectorDbClient *rag.VectorDbClient)
GetVectorDBClient() *rag.VectorDbClient
}
AICompanion defines the interface for interacting with AI models.
func NewCompanion ¶
func NewCompanion(config models.Configuration) AICompanion
NewCompanion creates a new Companion instance with the provided configuration.
Click to show internal directories.
Click to hide internal directories.