Documentation
¶
Index ¶
- type ChatMessage
- type Companion
- func (companion *Companion) AddMessage(message models.Message)
- func (companion *Companion) GetConfig() models.Configuration
- func (companion *Companion) GetConversation() []models.Message
- func (companion *Companion) GetEnrichmentPrompt() string
- func (companion *Companion) GetHttpClient() *http.Client
- func (companion *Companion) GetModels() ([]models.Model, error)
- func (companion *Companion) GetSummarizationPrompt() string
- func (companion *Companion) GetSystemRole() models.Message
- func (companion *Companion) HandleStreamResponse(resp *http.Response, streamType models.StreamType, ...) (models.Message, error)
- func (companion *Companion) PrepareConversation(message models.Message, includeStrategy models.IncludeStrategy) []models.Message
- func (companion *Companion) RunFunction(tool models.Tool, payload models.FunctionPayload) (models.FunctionResponse, error)
- func (companion *Companion) SendChatRequest(message models.MessageRequest, streaming bool, ...) (models.Message, error)
- func (companion *Companion) SendEmbeddingRequest(embedding models.EmbeddingRequest) (models.EmbeddingResponse, error)
- func (companion *Companion) SendGenerateRequest(message models.MessageRequest, streaming bool, ...) (models.Message, error)
- func (companion *Companion) SendModerationRequest(moderationRequest models.ModerationRequest) (models.ModerationResponse, error)
- func (companion *Companion) SendToolRequest(message models.MessageRequest) (models.Message, error)
- func (companion *Companion) SetConfig(config models.Configuration)
- func (companion *Companion) SetConversation(conversation []models.Message)
- func (companion *Companion) SetEnrichmentPrompt(enrichmentprompt string)
- func (companion *Companion) SetHttpClient(client *http.Client)
- func (companion *Companion) SetSummarizationPrompt(summarizationprompt string)
- func (companion *Companion) SetSystemRole(prompt string)
- type CompletionRequest
- type CompletionResponse
- type CopyModelRequest
- type CopyModelResponse
- type CreateModelRequest
- type CreateModelResponse
- type DeleteModelResponse
- type EmbeddingResponse
- type EmbeddingsRequest
- type ListModelsResponse
- type ModelInfoResponse
- type ModelResponse
- type PullModelRequest
- type PullModelResponse
- type PushModelRequest
- type PushModelResponse
- type RunningModelsResponse
- type VersionResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatMessage ¶
ChatMessage represents a message in the chat context.
type Companion ¶
type Companion struct {
Config models.Configuration
SystemRole models.Message
Conversation []models.Message
HttpClient *http.Client
}
Companion represents the AI companion with its configuration, conversation history, and HTTP client.
func (*Companion) AddMessage ¶
addMessage adds the given message to the conversation history.
func (*Companion) GetConfig ¶
func (companion *Companion) GetConfig() models.Configuration
GetConfig returns the current configuration of the companion.
func (*Companion) GetConversation ¶
GetConversation returns the current conversation history of the companion.
func (*Companion) GetEnrichmentPrompt ¶
GetEnrichmentPrompt returns the current enrichment prompt of the companion.
func (*Companion) GetHttpClient ¶
GetClient returns the current HTTP client of the companion.
func (*Companion) GetSummarizationPrompt ¶
GetSummarizationPrompt returns the current summarization prompt of the companion.
func (*Companion) GetSystemRole ¶
GetCurrentSystemRole returns the current system role of the companion.
func (*Companion) HandleStreamResponse ¶
func (companion *Companion) HandleStreamResponse(resp *http.Response, streamType models.StreamType, callback func(m models.Message) error) (models.Message, error)
HandleStreamResponse handles the streaming response from the Ollama API.
func (*Companion) PrepareConversation ¶
func (companion *Companion) PrepareConversation(message models.Message, includeStrategy models.IncludeStrategy) []models.Message
prepareConversation prepares the conversation by appending system role and current conversation messages.
func (*Companion) RunFunction ¶
func (companion *Companion) RunFunction(tool models.Tool, payload models.FunctionPayload) (models.FunctionResponse, error)
RunFunction executes a function with the provided payload.
func (*Companion) SendChatRequest ¶
func (companion *Companion) SendChatRequest(message models.MessageRequest, streaming bool, callback func(m models.Message) error) (models.Message, error)
ProcessUserInput processes the user input by sending it to the API and handling the response.
func (*Companion) SendEmbeddingRequest ¶
func (companion *Companion) SendEmbeddingRequest(embedding models.EmbeddingRequest) (models.EmbeddingResponse, error)
SendEmbeddingRequest sends an embedding request to the server using the provided embedding request object.
func (*Companion) SendGenerateRequest ¶
func (companion *Companion) SendGenerateRequest(message models.MessageRequest, streaming bool, callback func(m models.Message) error) (models.Message, error)
ProcessUserInput processes the user input by sending it to the API and handling the response.
func (*Companion) SendModerationRequest ¶
func (companion *Companion) SendModerationRequest(moderationRequest models.ModerationRequest) (models.ModerationResponse, error)
SendModerationRequest sends a request to the OpenAI API to moderate a given text input.
func (*Companion) SendToolRequest ¶ added in v0.3.4
func (*Companion) SetConfig ¶
func (companion *Companion) SetConfig(config models.Configuration)
SetConfig sets a new configuration for the companion.
func (*Companion) SetConversation ¶
SetConversation sets a new conversation history for the companion.
func (*Companion) SetEnrichmentPrompt ¶
SetEnrichmentPrompt sets a new enrichment prompt for the companion.
func (*Companion) SetHttpClient ¶
SetClient sets a new HTTP client for the companion.
func (*Companion) SetSummarizationPrompt ¶
SetSummarizationPrompt sets a new summarization prompt for the companion.
func (*Companion) SetSystemRole ¶
SetCurrentSystemRole sets a new system role for the companion.
type CompletionRequest ¶
type CompletionRequest struct {
Model string `json:"model"`
Messages []models.Message `json:"messages,omitempty"`
Prompt string `json:"prompt,omitempty"`
Suffix string `json:"suffix,omitempty"`
Images *[]models.Base64Image `json:"images,omitempty"`
Format string `json:"format,omitempty"`
Options string `json:"options,omitempty"`
System string `json:"system,omitempty"`
Template string `json:"template,omitempty"`
Stream bool `json:"stream"`
Raw bool `json:"raw,omitempty"`
KeepAlive int64 `json:"keep_alive,omitempty"`
Context string `json:"context,omitempty"`
Tools []models.Function `json:"tools,omitempty"`
}
GenerateRequest represents the request structure for the /api/generate endpoint.
type CompletionResponse ¶
type CompletionResponse struct {
Model string `json:"model"`
CreatedAt time.Time `json:"created_at"`
Done bool `json:"done"`
DoneReason string `json:"done_reason,omitempty"`
Message models.Message `json:"message,omitempty"`
Response string `json:"response,omitempty"`
TotalDuration int64 `json:"total_duration"`
LoadDuration int64 `json:"load_duration"`
PromptEvalCount int `json:"prompt_eval_count"`
PromptEvalDuration int64 `json:"prompt_eval_duration"`
EvalCount int `json:"eval_count"`
EvalDuration int64 `json:"eval_duration"`
// Context is an encoding of the conversation used in this response; this
// can be sent in the next request to keep a conversational memory.
Context []int `json:"context,omitempty"`
}
ChatResponse represents the response structure for the /api/chat endpoint.
type CopyModelRequest ¶
type CopyModelRequest struct {
Source string `json:"source"`
Destination string `json:"destination"`
}
CopyModelRequest represents the request structure for the /api/models/copy endpoint.
type CopyModelResponse ¶
type CopyModelResponse struct {
Message string `json:"message"`
}
CopyModelResponse represents the response structure for the /api/models/copy endpoint.
type CreateModelRequest ¶
CreateModelRequest represents the request structure for the /api/models/create endpoint.
type CreateModelResponse ¶
type CreateModelResponse struct {
Message string `json:"message"`
}
CreateModelResponse represents the response structure for the /api/models/create endpoint.
type DeleteModelResponse ¶
type DeleteModelResponse struct {
Message string `json:"message"`
}
DeleteModelResponse represents the response structure for the /api/models/{model} DELETE endpoint.
type EmbeddingResponse ¶
type EmbeddingResponse struct {
Model string `json:"model"`
Embeddings [][]float32 `json:"embeddings"`
TotalDuration int64 `json:"total_duration,omitempty"`
LoadDuration int64 `json:"load_duration,omitempty"`
PromptEvalCount int `json:"prompt_eval_count,omitempty"`
}
EmbeddingsResponse represents the response structure for the /api/embeddings endpoint.
type EmbeddingsRequest ¶
EmbeddingsRequest represents the request structure for the /api/embeddings endpoint.
type ListModelsResponse ¶
type ListModelsResponse struct {
Models []string `json:"models"`
}
ListModelsResponse represents the response structure for the /api/models endpoint.
type ModelInfoResponse ¶
ModelInfoResponse represents the response structure for the /api/models/{model} endpoint.
type ModelResponse ¶
ModelResponse represents the response structure for the models endpoint.
type PullModelRequest ¶
type PullModelRequest struct {
Model string `json:"model"`
}
PullModelRequest represents the request structure for the /api/models/pull endpoint.
type PullModelResponse ¶
type PullModelResponse struct {
Message string `json:"message"`
}
PullModelResponse represents the response structure for the /api/models/pull endpoint.
type PushModelRequest ¶
type PushModelRequest struct {
Model string `json:"model"`
}
PushModelRequest represents the request structure for the /api/models/push endpoint.
type PushModelResponse ¶
type PushModelResponse struct {
Message string `json:"message"`
}
PushModelResponse represents the response structure for the /api/models/push endpoint.
type RunningModelsResponse ¶
type RunningModelsResponse struct {
RunningModels []string `json:"running_models"`
}
RunningModelsResponse represents the response structure for the /api/models/running endpoint.
type VersionResponse ¶
type VersionResponse struct {
Version string `json:"version"`
}
VersionResponse represents the response structure for the /api/version endpoint.