Versions in this module Expand all Collapse all v0 v0.0.1 Oct 31, 2024 Changes in this version + type Backend interface + Embed func(ctx context.Context, input string) ([]float32, error) + Generate func(ctx context.Context, prompt *Prompt) (string, error) + type Message struct + Content string + Role string + type OllamaBackend struct + BaseURL string + Client *http.Client + Model string + func NewOllamaBackend(baseURL, model string, timeout time.Duration) *OllamaBackend + func (o *OllamaBackend) Embed(ctx context.Context, input string) ([]float32, error) + func (o *OllamaBackend) Generate(ctx context.Context, prompt *Prompt) (string, error) + type OllamaEmbeddingResponse struct + Embedding []float32 + type OpenAIBackend struct + APIKey string + BaseURL string + HTTPClient *http.Client + Model string + func NewOpenAIBackend(apiKey, model string, timeout time.Duration) *OpenAIBackend + func (o *OpenAIBackend) Embed(ctx context.Context, text string) ([]float32, error) + func (o *OpenAIBackend) Generate(ctx context.Context, prompt *Prompt) (string, error) + type OpenAIEmbeddingResponse struct + Data []struct{ ... } + Model string + Object string + Usage struct{ ... } + type OpenAIResponse struct + Choices []struct{ ... } + Created int64 + ID string + Model string + Object string + Usage struct{ ... } + type Parameters struct + FrequencyPenalty float64 + MaxTokens int + PresencePenalty float64 + Temperature float64 + TopP float64 + type Prompt struct + Messages []Message + Parameters Parameters + func NewPrompt() *Prompt + func (p *Prompt) AddMessage(role, content string) *Prompt + func (p *Prompt) SetParameters(params Parameters) *Prompt + type Response struct + Context []int + CreatedAt string + Done bool + DoneReason string + EvalCount int + EvalDuration int64 + LoadDuration int64 + Model string + PromptEvalCount int + PromptEvalDuration int64 + Response string + TotalDuration int64