Documentation
¶
Index ¶
Constants ¶
View Source
const ( SystemPrompt = "You are a helpful assistant" EnrichmentPrompt = "Answer the following query with the provided context" SummarizationPrompt = "" /* 145-byte string literal not displayed */ DefaultHTTPTimeout = 300 DefaultMaxMessages = 20 )
Variables ¶
View Source
var OllamaEndpoints = models.ApiEndpointUrls{
ApiChatURL: "http://localhost:11434/api/chat",
ApiGenerateURL: "http://localhost:11434/api/generate",
ApiEmbedURL: "http://localhost:11434/api/embed",
ApiModerationURL: "http://localhost:11434/api/generate",
ApiModelsURL: "http://localhost:11434/api/tags",
}
View Source
var OpenAIEndpoints = models.ApiEndpointUrls{
ApiChatURL: "https://api.openai.com/v1/chat/completions",
ApiGenerateURL: "https://api.openai.com/v1/completions",
ApiEmbedURL: "https://api.openai.com/v1/embeddings",
ApiModerationURL: "https://api.openai.com/v1/moderations",
ApiModelsURL: "https://api.openai.com/v1/models",
}
Functions ¶
func NewDefaultConfig ¶ added in v0.1.4
func NewDefaultConfig(apiProvider models.ApiProvider, apiToken, chatModel, generateModel, embeddingModel 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 prepares the conversation by appending system role and current conversation messages.
PrepareConversation(message models.Message, includeStrategy models.IncludeStrategy) []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)
// 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
GetHttpClient() *http.Client
// SetClient sets a new HTTP client for requests
SetHttpClient(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.MessageRequest, 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.MessageRequest, 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 handles streaming responses from an HTTP request.
HandleStreamResponse(resp *http.Response, streamType models.StreamType, callback func(m models.Message) error) (models.Message, error)
SendToolRequest(message models.MessageRequest) (models.Message, error)
// RunFunction runs a function and returns the response
RunFunction(tool models.Tool, payload models.FunctionPayload) (models.FunctionResponse, error)
}
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.