Documentation
¶
Index ¶
- type BlobCheckFunc
- type BlobCreateFunc
- type Chat
- type ChatFunc
- func (f *ChatFunc) WithFormat(v string) func(*ChatRequestBuilder)
- func (f *ChatFunc) WithKeepAlive(v string) func(*ChatRequestBuilder)
- func (f *ChatFunc) WithMessage(v Message) func(*ChatRequestBuilder)
- func (f *ChatFunc) WithModel(v string) func(*ChatRequestBuilder)
- func (f *ChatFunc) WithOptions(v Options) func(*ChatRequestBuilder)
- func (f *ChatFunc) WithRaw(v bool) func(*ChatRequestBuilder)
- func (f *ChatFunc) WithSeed(v int) func(*ChatRequestBuilder)
- func (f *ChatFunc) WithStream(v bool, bufferSize int, fn func(r *ChatResponse, err error)) func(*ChatRequestBuilder)
- func (f *ChatFunc) WithTemperature(v float64) func(*ChatRequestBuilder)
- type ChatRequestBuilder
- type ChatResponse
- type CopyModelFunc
- type CreateModelFunc
- func (f *CreateModelFunc) WithAdapter(v string) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithChat(chat *Chat) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithFrom(v string) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithLicense(v string) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithMessage(v Message) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithModel(v string) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithParameter(v Parameter) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithPath(v string) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithQuantize(v string) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithStream(v bool, bufferSize int, fc func(r *StatusResponse, err error)) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithSystem(v string) func(*ModelFileRequestBuilder)
- func (f *CreateModelFunc) WithTemplate(v string) func(*ModelFileRequestBuilder)
- type DeleteModelFunc
- type GenerateEmbeddingsFunc
- func (c GenerateEmbeddingsFunc) WithKeepAlive(v string) func(*GenerateEmbeddingsRequestBuilder)
- func (c GenerateEmbeddingsFunc) WithModel(v string) func(*GenerateEmbeddingsRequestBuilder)
- func (c GenerateEmbeddingsFunc) WithOptions(v Options) func(*GenerateEmbeddingsRequestBuilder)
- func (c GenerateEmbeddingsFunc) WithPrompt(v string) func(*GenerateEmbeddingsRequestBuilder)
- type GenerateEmbeddingsRequestBuilder
- type GenerateEmbeddingsResponse
- type GenerateFunc
- func (c GenerateFunc) WithContext(v []int) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithFormat(v string) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithImage(v string) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithKeepAlive(v string) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithModel(v string) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithOptions(v Options) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithPrompt(v string) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithRaw(v bool) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithSeed(v int) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithStream(v bool, bufferSize int, f func(r *GenerateResponse, err error)) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithSystem(v string) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithTemperature(v float64) func(*GenerateRequestBuilder)
- func (c GenerateFunc) WithTemplate(v string) func(*GenerateRequestBuilder)
- type GenerateRequestBuilder
- type GenerateResponse
- type ListLocalModelsFunc
- type ListLocalModelsResponse
- type Message
- type Metrics
- type ModelDetails
- type ModelFileRequestBuilder
- type ModelResponse
- type Ollama
- type Options
- type Parameter
- type PullModelFunc
- func (f *PullModelFunc) WithInsecure(v bool) func(*PullModelRequestBuilder)
- func (f *PullModelFunc) WithModel(v string) func(*PullModelRequestBuilder)
- func (f *PullModelFunc) WithPassword(v string) func(*PullModelRequestBuilder)
- func (f *PullModelFunc) WithStream(v bool, bufferSize int, fc func(r *PushPullModelResponse, err error)) func(*PullModelRequestBuilder)
- func (f *PullModelFunc) WithUsername(v string) func(*PullModelRequestBuilder)
- type PullModelRequestBuilder
- type PushModelFunc
- func (f *PushModelFunc) WithInsecure(v bool) func(*PushModelRequestBuilder)
- func (f *PushModelFunc) WithModel(v string) func(*PushModelRequestBuilder)
- func (f *PushModelFunc) WithPassword(v string) func(*PushModelRequestBuilder)
- func (f *PushModelFunc) WithStream(v bool, bufferSize int, fc func(r *PushPullModelResponse, err error)) func(*PushModelRequestBuilder)
- func (f *PushModelFunc) WithUsername(v string) func(*PushModelRequestBuilder)
- type PushModelRequestBuilder
- type PushPullModelResponse
- type ShowModelInfoFunc
- func (f *ShowModelInfoFunc) WithModel(v string) func(*ShowModelRequestBuilder)
- func (f *ShowModelInfoFunc) WithOptions(v Options) func(*ShowModelRequestBuilder)
- func (f *ShowModelInfoFunc) WithSystem(v string) func(*ShowModelRequestBuilder)
- func (f *ShowModelInfoFunc) WithTemplate(v string) func(*ShowModelRequestBuilder)
- type ShowModelInfoResponse
- type ShowModelRequestBuilder
- type StatusResponse
- type VersionFunc
- type VersionResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlobCheckFunc ¶
BlobCheckFunc performs a request to the Ollama API to check if a blob file exists.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
type BlobCreateFunc ¶
BlobCreateFunc performs a request to the Ollama API to create a new blob with the provided blob file.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
type Chat ¶
Chat stores the messages sent from the user and received from the assistant.
func (*Chat) AddMessage ¶
AddMessage adds a new message to the end of the chat.
Parameters:
- m: The message to add.
func (*Chat) AddMessageTo ¶
AddMessageTo adds a new message at the specified index.
Parameters:
- index: The index at which to add the new message.
- m: The message to add.
func (*Chat) DeleteAllMessages ¶
func (c *Chat) DeleteAllMessages()
DeleteAllMessages deletes all messages in the chat.
func (*Chat) DeleteMessage ¶
DeleteMessage deletes a message at the specified index.
Parameters:
- index: The index of the message to delete.
type ChatFunc ¶
type ChatFunc func(chatId *string, builder ...func(reqBuilder *ChatRequestBuilder)) (*ChatResponse, error)
ChatFunc performs a request to the Ollama API with the provided instructions. If chatId is set, it will append the messages from previous requests to the current request. If chatId is not found, a new chat will be generated.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
func (*ChatFunc) WithFormat ¶
func (f *ChatFunc) WithFormat(v string) func(*ChatRequestBuilder)
WithFormat sets the format to return a response in. Currently, the only accepted value is "json".
Parameters:
- v: The format string.
func (*ChatFunc) WithKeepAlive ¶ added in v1.0.4
func (f *ChatFunc) WithKeepAlive(v string) func(*ChatRequestBuilder)
WithKeepAlive controls how long the model will stay loaded into memory following the request.
Parameters:
- v: The keep alive duration.
func (*ChatFunc) WithMessage ¶
func (f *ChatFunc) WithMessage(v Message) func(*ChatRequestBuilder)
WithMessage appends a new message to the request.
Parameters:
- v: The message to append.
func (*ChatFunc) WithModel ¶
func (f *ChatFunc) WithModel(v string) func(*ChatRequestBuilder)
WithModel sets the model used for this request.
Parameters:
- v: The model name.
func (*ChatFunc) WithOptions ¶
func (f *ChatFunc) WithOptions(v Options) func(*ChatRequestBuilder)
WithOptions sets the options for this request. It will override any settings set before, such as temperature and seed.
Parameters:
- v: The options to set.
func (*ChatFunc) WithRaw ¶
func (f *ChatFunc) WithRaw(v bool) func(*ChatRequestBuilder)
WithRaw bypasses the templating system and provides a full prompt.
Parameters:
- v: A boolean indicating whether to use raw mode.
func (*ChatFunc) WithSeed ¶
func (f *ChatFunc) WithSeed(v int) func(*ChatRequestBuilder)
WithSeed sets the seed for this request.
Parameters:
- v: The seed value.
func (*ChatFunc) WithStream ¶
func (f *ChatFunc) WithStream(v bool, bufferSize int, fn func(r *ChatResponse, err error)) func(*ChatRequestBuilder)
WithStream passes a function to allow reading stream
Parameters:
- v: A boolean indicating whether to use streaming.
- bufferSize: The size of the streamed buffer
- f: The function to handle streaming
func (*ChatFunc) WithTemperature ¶
func (f *ChatFunc) WithTemperature(v float64) func(*ChatRequestBuilder)
WithTemperature sets the temperature for this request.
Parameters:
- v: The temperature value.
type ChatRequestBuilder ¶
type ChatRequestBuilder struct { Model *string `json:"model"` Format *string `json:"format"` Raw *bool `json:"raw"` Messages []Message `json:"messages"` KeepAlive *string `json:"keep_alive,omitempty"` Options *Options `json:"options"` Stream *bool `json:"stream"` StreamBufferSize *int `json:"-"` StreamFunc func(r *ChatResponse, err error) `json:"-"` }
ChatRequestBuilder represents the chat API request.
type ChatResponse ¶ added in v1.0.4
type ChatResponse struct { Model string `json:"model"` // Is the model name that generated the response. CreatedAt string `json:"created_at"` // Is the timestamp of the response. Message Message `json:"message"` Done bool `json:"done"` // Specifies if the response is complete. DoneReason string `json:"done_reason"` // The reason the model stopped generating text. Context []int `json:"context"` // Is an encoding of the conversation used in this response; this can be sent in the next request to keep a conversational memory. Metrics }
ChatResponse represents the API response for "chat" endpoint.
type CopyModelFunc ¶
CopyModelFunc performs a request to the Ollama API to copy an existing model under a different name.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
type CreateModelFunc ¶
type CreateModelFunc func(builder ...func(modelFileBuilder *ModelFileRequestBuilder)) (*StatusResponse, error)
CreateModelFunc performs a request to the Ollama API to create a new model with the provided model file. Canceled pulls are resumed from where they left off, and multiple calls will share the same download progress.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
func (*CreateModelFunc) WithAdapter ¶
func (f *CreateModelFunc) WithAdapter(v string) func(*ModelFileRequestBuilder)
WithAdapter defines the (Q)LoRA adapters to apply to the model.
Parameters:
- v: The adapter string.
func (*CreateModelFunc) WithChat ¶
func (f *CreateModelFunc) WithChat(chat *Chat) func(*ModelFileRequestBuilder)
WithChat appends all the messages from a chat to the message history.
Parameters:
- chat: The chat whose messages to append.
func (*CreateModelFunc) WithFrom ¶
func (f *CreateModelFunc) WithFrom(v string) func(*ModelFileRequestBuilder)
WithFrom defines the base model to use.
Parameters:
- v: The base model string.
func (*CreateModelFunc) WithLicense ¶
func (f *CreateModelFunc) WithLicense(v string) func(*ModelFileRequestBuilder)
WithLicense specifies the legal license.
Parameters:
- v: The license string.
func (*CreateModelFunc) WithMessage ¶
func (f *CreateModelFunc) WithMessage(v Message) func(*ModelFileRequestBuilder)
WithMessage appends a new message to the message history.
Parameters:
- v: The message to append.
func (*CreateModelFunc) WithModel ¶ added in v1.0.4
func (f *CreateModelFunc) WithModel(v string) func(*ModelFileRequestBuilder)
WithModel sets the new model's name for this request.
Parameters:
- v: The model name.
func (*CreateModelFunc) WithParameter ¶
func (f *CreateModelFunc) WithParameter(v Parameter) func(*ModelFileRequestBuilder)
WithParameter appends a new parameter for how Ollama will run the model.
Parameters:
- v: The parameter to append.
func (*CreateModelFunc) WithPath ¶ added in v1.0.4
func (f *CreateModelFunc) WithPath(v string) func(*ModelFileRequestBuilder)
WithPath sets the path for this request.
Parameters:
- v: The path.
func (*CreateModelFunc) WithQuantize ¶ added in v1.0.4
func (f *CreateModelFunc) WithQuantize(v string) func(*ModelFileRequestBuilder)
WithQuantize sets the quantize for this request.
Parameters:
- v: The quantize value.
func (*CreateModelFunc) WithStream ¶
func (f *CreateModelFunc) WithStream(v bool, bufferSize int, fc func(r *StatusResponse, err error)) func(*ModelFileRequestBuilder)
WithStream passes a function to allow reading stream types.
Parameters:
- v: A boolean indicating whether to use streaming.
- bufferSize: The size of the streamed buffer
- fc: The function to handle streaming types.
func (*CreateModelFunc) WithSystem ¶
func (f *CreateModelFunc) WithSystem(v string) func(*ModelFileRequestBuilder)
WithSystem specifies the system message that will be set in the template.
Parameters:
- v: The system message string.
func (*CreateModelFunc) WithTemplate ¶
func (f *CreateModelFunc) WithTemplate(v string) func(*ModelFileRequestBuilder)
WithTemplate sets the full prompt template to be sent to the model.
Parameters:
- v: The template string.
type DeleteModelFunc ¶
DeleteModelFunc performs a request to the Ollama API to delete a model.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
type GenerateEmbeddingsFunc ¶
type GenerateEmbeddingsFunc func(...func(modelFileBuilder *GenerateEmbeddingsRequestBuilder)) (*GenerateEmbeddingsResponse, error)
GenerateEmbeddingsFunc performs a request to the Ollama API to generate embeddings from a model.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
func (GenerateEmbeddingsFunc) WithKeepAlive ¶
func (c GenerateEmbeddingsFunc) WithKeepAlive(v string) func(*GenerateEmbeddingsRequestBuilder)
WithKeepAlive controls how long the model will stay loaded into memory following the request (default: 5m).
Parameters:
- v: The keep alive string.
func (GenerateEmbeddingsFunc) WithModel ¶
func (c GenerateEmbeddingsFunc) WithModel(v string) func(*GenerateEmbeddingsRequestBuilder)
WithModel sets the model used for this request.
Parameters:
- v: The model name.
func (GenerateEmbeddingsFunc) WithOptions ¶
func (c GenerateEmbeddingsFunc) WithOptions(v Options) func(*GenerateEmbeddingsRequestBuilder)
WithOptions sets the options for this request. It will override any settings set before, such as temperature and seed.
Parameters:
- v: The options to set.
func (GenerateEmbeddingsFunc) WithPrompt ¶
func (c GenerateEmbeddingsFunc) WithPrompt(v string) func(*GenerateEmbeddingsRequestBuilder)
WithPrompt sets the prompt for this request.
Parameters:
- v: The prompt string.
type GenerateEmbeddingsRequestBuilder ¶ added in v1.0.4
type GenerateEmbeddingsRequestBuilder struct { Model *string `json:"model"` Prompt *string `json:"prompt"` KeepAlive *string `json:"keep_alive"` Options *Options `json:"options"` }
GenerateEmbeddingsRequestBuilder represents the generate embeddings API request.
type GenerateEmbeddingsResponse ¶
type GenerateEmbeddingsResponse struct {
Embedding []float64 `json:"embedding"`
}
GenerateEmbeddingsResponse represents the API response for "generate embeddings" endpoint.
type GenerateFunc ¶
type GenerateFunc func(builder ...func(reqBuilder *GenerateRequestBuilder)) (*GenerateResponse, error)
GenerateFunc performs a request to the Ollama API with the provided instructions. If the prompt is not set, the model will be loaded into memory.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
func (GenerateFunc) WithContext ¶ added in v1.0.4
func (c GenerateFunc) WithContext(v []int) func(*GenerateRequestBuilder)
WithContext overrides the model's default prompt template.
Parameters:
- v: The content int array.
func (GenerateFunc) WithFormat ¶
func (c GenerateFunc) WithFormat(v string) func(*GenerateRequestBuilder)
WithFormat sets the format to return a response in. Currently, the only accepted value is "json".
Parameters:
- v: The format string.
func (GenerateFunc) WithImage ¶
func (c GenerateFunc) WithImage(v string) func(*GenerateRequestBuilder)
WithImage appends an image to the message sent to Ollama. The image must be base64 encoded.
Parameters:
- v: The base64 encoded image string.
func (GenerateFunc) WithKeepAlive ¶ added in v1.0.4
func (c GenerateFunc) WithKeepAlive(v string) func(*GenerateRequestBuilder)
WithKeepAlive controls how long the model will stay loaded in memory following this request.
Parameters:
- v: The keep alive duration.
func (GenerateFunc) WithModel ¶
func (c GenerateFunc) WithModel(v string) func(*GenerateRequestBuilder)
WithModel sets the model used for this request.
Parameters:
- v: The model name.
func (GenerateFunc) WithOptions ¶
func (c GenerateFunc) WithOptions(v Options) func(*GenerateRequestBuilder)
WithOptions sets the options for this request. It will override any settings set before, such as temperature and seed.
Parameters:
- v: The options to set.
func (GenerateFunc) WithPrompt ¶
func (c GenerateFunc) WithPrompt(v string) func(*GenerateRequestBuilder)
WithPrompt sets the prompt for this request.
Parameters:
- v: The prompt string.
func (GenerateFunc) WithRaw ¶
func (c GenerateFunc) WithRaw(v bool) func(*GenerateRequestBuilder)
WithRaw bypasses the templating system and provides a full prompt.
Parameters:
- v: A boolean indicating whether to use raw mode.
func (GenerateFunc) WithSeed ¶
func (c GenerateFunc) WithSeed(v int) func(*GenerateRequestBuilder)
WithSeed sets the seed for this request.
Parameters:
- v: The seed value.
func (GenerateFunc) WithStream ¶
func (c GenerateFunc) WithStream(v bool, bufferSize int, f func(r *GenerateResponse, err error)) func(*GenerateRequestBuilder)
WithStream passes a function to allow reading stream types.
Parameters:
- v: A boolean indicating whether to use streaming.
- bufferSize: The size of the streamed buffer
- f: The function to handle streaming types.
func (GenerateFunc) WithSystem ¶ added in v1.0.4
func (c GenerateFunc) WithSystem(v string) func(*GenerateRequestBuilder)
WithSystem overrides the model's default system message/prompt.
Parameters:
- v: The system string.
func (GenerateFunc) WithTemperature ¶
func (c GenerateFunc) WithTemperature(v float64) func(*GenerateRequestBuilder)
WithTemperature sets the temperature for this request.
Parameters:
- v: The temperature value.
func (GenerateFunc) WithTemplate ¶ added in v1.0.4
func (c GenerateFunc) WithTemplate(v string) func(*GenerateRequestBuilder)
WithTemplate overrides the model's default prompt template.
Parameters:
- v: The template string.
type GenerateRequestBuilder ¶
type GenerateRequestBuilder struct { Model *string `json:"model"` Prompt *string `json:"prompt"` System *string `json:"system"` Template *string `json:"template"` Format *string `json:"format"` Images []string `json:"images"` Raw *bool `json:"raw"` Context []int `json:"context,omitempty"` KeepAlive *string `json:"keep_alive,omitempty"` Options *Options `json:"options"` Stream *bool `json:"stream"` StreamBufferSize *int `json:"-"` StreamFunc func(r *GenerateResponse, err error) `json:"-"` }
GenerateRequestBuilder represents the generate API request.
type GenerateResponse ¶ added in v1.0.4
type GenerateResponse struct { Model string `json:"model"` // Is the model name that generated the response. CreatedAt string `json:"created_at"` // Is the timestamp of the response. Response string `json:"response"` // Is the textual response itself. Done bool `json:"done"` // Specifies if the response is complete. DoneReason string `json:"done_reason"` // The reason the model stopped generating text. Context []int `json:"context"` // Is an encoding of the conversation used in this response; this can be sent in the next request to keep a conversational memory. Metrics }
GenerateResponse represents the API response for "generate" endpoint.
type ListLocalModelsFunc ¶
type ListLocalModelsFunc func() (*ListLocalModelsResponse, error)
ListLocalModelsFunc performs a request to the Ollama API to retrieve the local models.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
type ListLocalModelsResponse ¶
type ListLocalModelsResponse struct {
Models []ModelResponse `json:"models"`
}
ListLocalModelsResponse represents the response for listing local models.
type Message ¶
type Message struct { Role *string `json:"role"` // Role of the message, either system, user, or assistant. Content *string `json:"content"` // Content of the message. Images []string `json:"images"` // Images associated with the message. }
Message represents a message sent/received from the API.
type Metrics ¶ added in v1.0.4
type Metrics struct { TotalDuration time.Duration `json:"total_duration"` LoadDuration time.Duration `json:"load_duration"` PromptEvalCount int `json:"prompt_eval_count"` PromptEvalDuration time.Duration `json:"prompt_eval_duration"` EvalCount int `json:"eval_count"` EvalDuration time.Duration `json:"eval_duration"` }
type ModelDetails ¶
type ModelDetails struct { Format string `json:"format"` Family string `json:"family"` Families []string `json:"families"` ParameterSize string `json:"parameter_size"` QuantizationLevel string `json:"quantization_level"` }
ModelDetails represents detailed information about a model.
type ModelFileRequestBuilder ¶ added in v1.0.4
type ModelFileRequestBuilder struct { Model *string `json:"model"` Path *string `json:"path"` Modelfile *string `json:"modelfile"` Quantize *string `json:"quantize"` Stream *bool `json:"stream"` StreamBufferSize *int `json:"-"` StreamFunc func(r *StatusResponse, err error) `json:"-"` // contains filtered or unexported fields }
ModelFileRequestBuilder represents the model creation API request.
func (*ModelFileRequestBuilder) Build ¶ added in v1.0.4
func (m *ModelFileRequestBuilder) Build() string
Build generates the ModelFile.
Parameters:
- defaultModel: The default model string.
type ModelResponse ¶ added in v1.0.4
type ModelResponse struct { Name string `json:"name"` Model string `json:"model"` ModifiedAt string `json:"modified_at"` Size int64 `json:"size"` Digest string `json:"digest"` Details ModelDetails `json:"details"` ExpiresAt time.Time `json:"expires_at"` SizeVRAM int64 `json:"size_vram"` }
ModelResponse represents a model's metadata.
type Ollama ¶
type Ollama struct { Http *http.Client Chat ChatFunc Generate GenerateFunc Blobs struct { Check BlobCheckFunc Create BlobCreateFunc } Models struct { Create CreateModelFunc List ListLocalModelsFunc ShowInfo ShowModelInfoFunc Copy CopyModelFunc Delete DeleteModelFunc Pull PullModelFunc Push PushModelFunc } GenerateEmbeddings GenerateEmbeddingsFunc // contains filtered or unexported fields }
Ollama represents a client for interacting with the Ollama API.
func New ¶
New creates a new Ollama client that points to the specified URL. It initializes the client with default settings and available API functions.
Example:
llm := New("http://api.ollama.com")
func (*Ollama) DeleteAllChats ¶
func (o *Ollama) DeleteAllChats()
DeleteAllChats removes all chats from the client's chat map.
func (*Ollama) DeleteChat ¶
DeleteChat removes a chat by its ID.
Parameters:
- id: The ID of the chat to remove.
func (*Ollama) GetChat ¶
GetChat retrieves a chat by its ID.
Parameters:
- id: The ID of the chat.
Returns:
- A pointer to the Chat if found, or nil if not found.
func (*Ollama) PreloadChat ¶
PreloadChat preloads a chat into the client's chat map.
Parameters:
- chat: The chat to preload.
func (*Ollama) SetHeaders ¶ added in v1.1.0
SetHeaders sets the headers for all the requests.
type Options ¶
type Options struct { NumKeep *int `json:"num_keep"` NumPredict *int `json:"num_predict"` // Max number of tokens to predict. TopK *int `json:"top_k"` // Reduces the probability of generating nonsense. TopP *float64 `json:"top_p"` // Controls diversity of text. TfsZ *float64 `json:"tfs_z"` // Tail free sampling. TypicalP *float64 `json:"typical_p"` // Typical probability. RepeatLastN *int `json:"repeat_last_n"` // Prevents repetition. PenalizeNewLine *bool `json:"penalize_newline"` // Penalizes new lines. RepeatPenalty *float64 `json:"repeat_penalty"` // Penalizes repetitions. PresencePenalty *float64 `json:"presence_penalty"` // Penalizes presence of tokens. FrequencyPenalty *float64 `json:"frequency_penalty"` // Penalizes frequency of tokens. Mirostat *int `json:"mirostat"` // Enables Mirostat sampling. MirostatEta *float64 `json:"mirostat_eta"` // Learning rate for Mirostat. MirostatTau *float64 `json:"mirostat_tau"` // Balance between coherence and diversity. Stop []string `json:"stop"` // Stop sequences. Numa *bool `json:"numa"` // NUMA support. NumCtx *int `json:"num_ctx"` // Context window size. NumBatch *int `json:"num_batch"` // Batch size. NumGPU *int `json:"num_gpu"` // Number of GPUs. LowVRam *bool `json:"low_vram"` // Low VRAM mode. F16KV *bool `json:"f16_kv"` // 16-bit key-value pairs. VocabOnly *bool `json:"vocab_only"` // Vocab only mode. NumThreads *int `json:"num_threads"` // Number of threads. UseMMap *bool `json:"use_mmap"` // Use memory-mapped files. UseMLock *bool `json:"use_mlock"` // Use memory locking. Seed *int `json:"seed"` // Random seed. Temperature *float64 `json:"temperature"` // Temperature for generation. }
Options represents the options that will be sent to the API.
type PullModelFunc ¶
type PullModelFunc func(...func(modelFileBuilder *PullModelRequestBuilder)) (*PushPullModelResponse, error)
PullModelFunc performs a request to the Ollama API to pull model from the ollama library.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
func (*PullModelFunc) WithInsecure ¶
func (f *PullModelFunc) WithInsecure(v bool) func(*PullModelRequestBuilder)
WithInsecure allows insecure connections to the library. Only use this if you are pulling from your own library during development.
Parameters:
- v: A boolean indicating whether to insecure mode.
func (*PullModelFunc) WithModel ¶ added in v1.0.4
func (f *PullModelFunc) WithModel(v string) func(*PullModelRequestBuilder)
WithModel sets the model used for this request.
Parameters:
- v: The model name.
func (*PullModelFunc) WithPassword ¶ added in v1.0.4
func (f *PullModelFunc) WithPassword(v string) func(*PullModelRequestBuilder)
WithPassword sets the password used for this request.
Parameters:
- v: The password.
func (*PullModelFunc) WithStream ¶
func (f *PullModelFunc) WithStream(v bool, bufferSize int, fc func(r *PushPullModelResponse, err error)) func(*PullModelRequestBuilder)
WithStream passes a function to allow reading stream types.
Parameters:
- v: A boolean indicating whether to use streaming.
- bufferSize: The size of the streamed buffer
- fc: The function to handle streaming types.
func (*PullModelFunc) WithUsername ¶ added in v1.0.4
func (f *PullModelFunc) WithUsername(v string) func(*PullModelRequestBuilder)
WithUsername sets the username used for this request.
Parameters:
- v: The username.
type PullModelRequestBuilder ¶ added in v1.0.4
type PullModelRequestBuilder struct { Model *string `json:"model"` Insecure *bool `json:"insecure"` Username *string `json:"username"` Password *string `json:"password"` Stream *bool `json:"stream"` StreamBufferSize *int `json:"-"` StreamFunc func(r *PushPullModelResponse, err error) `json:"-"` }
PullModelRequestBuilder represents the pull model API request.
type PushModelFunc ¶
type PushModelFunc func(...func(modelFileBuilder *PushModelRequestBuilder)) (*PushPullModelResponse, error)
PushModelFunc performs a request to the Ollama API to push model to the ollama library. Requires registering for ollama.ai and adding a public key first
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
func (*PushModelFunc) WithInsecure ¶
func (f *PushModelFunc) WithInsecure(v bool) func(*PushModelRequestBuilder)
WithInsecure allows insecure connections to the library. Only use this if you are pulling from your own library during development.
Parameters:
- v: A boolean indicating whether to insecure mode.
func (*PushModelFunc) WithModel ¶ added in v1.0.4
func (f *PushModelFunc) WithModel(v string) func(*PushModelRequestBuilder)
WithModel sets the model used for this request.
Parameters:
- v: The model name.
func (*PushModelFunc) WithPassword ¶ added in v1.0.4
func (f *PushModelFunc) WithPassword(v string) func(*PushModelRequestBuilder)
WithPassword sets the password used for this request.
Parameters:
- v: The password.
func (*PushModelFunc) WithStream ¶
func (f *PushModelFunc) WithStream(v bool, bufferSize int, fc func(r *PushPullModelResponse, err error)) func(*PushModelRequestBuilder)
WithStream passes a function to allow reading stream types.
Parameters:
- v: A boolean indicating whether to use streaming.
- bufferSize: The size of the streamed buffer
- fc: The function to handle streaming types.
func (*PushModelFunc) WithUsername ¶ added in v1.0.4
func (f *PushModelFunc) WithUsername(v string) func(*PushModelRequestBuilder)
WithUsername sets the username used for this request.
Parameters:
- v: The username.
type PushModelRequestBuilder ¶ added in v1.0.4
type PushModelRequestBuilder struct { Model *string `json:"model"` Insecure *bool `json:"insecure"` Username *string `json:"username"` Password *string `json:"password"` Stream *bool `json:"stream"` StreamBufferSize *int `json:"-"` StreamFunc func(r *PushPullModelResponse, err error) `json:"-"` }
PushModelRequestBuilder represents the push model API request.
type PushPullModelResponse ¶ added in v1.0.4
type PushPullModelResponse struct { Status string `json:"status"` Error string `json:"error"` Digest string `json:"digest"` Total int64 `json:"total"` Completed int64 `json:"completed"` }
PushPullModelResponse represents the API response for "model push" endpoint.
type ShowModelInfoFunc ¶
type ShowModelInfoFunc func(builder ...func(reqBuilder *ShowModelRequestBuilder)) (*ShowModelInfoResponse, error)
ShowModelInfoFunc performs a request to the Ollama API to retrieve the information of a model.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
func (*ShowModelInfoFunc) WithModel ¶ added in v1.0.4
func (f *ShowModelInfoFunc) WithModel(v string) func(*ShowModelRequestBuilder)
WithModel sets the new model's name for this request.
Parameters:
- v: The model name.
func (*ShowModelInfoFunc) WithOptions ¶ added in v1.0.4
func (f *ShowModelInfoFunc) WithOptions(v Options) func(*ShowModelRequestBuilder)
WithOptions sets the options for this request. It will override any settings set before, such as temperature and seed.
Parameters:
- v: The options to set.
func (*ShowModelInfoFunc) WithSystem ¶ added in v1.0.4
func (f *ShowModelInfoFunc) WithSystem(v string) func(*ShowModelRequestBuilder)
WithSystem sets the system for this request.
Parameters:
- v: The system message string.
func (*ShowModelInfoFunc) WithTemplate ¶ added in v1.0.4
func (f *ShowModelInfoFunc) WithTemplate(v string) func(*ShowModelRequestBuilder)
WithTemplate sets the template for this request.
Parameters:
- v: The template string.
type ShowModelInfoResponse ¶
type ShowModelInfoResponse struct { License string `json:"license"` Modelfile string `json:"modelfile"` Parameters string `json:"parameters"` Template string `json:"template"` System string `json:"system"` Details ModelDetails `json:"details"` Messages []Message `json:"messages"` }
ShowModelInfoResponse represents the response for showing model information.
type ShowModelRequestBuilder ¶ added in v1.0.4
type ShowModelRequestBuilder struct { Model *string `json:"model"` System *string `json:"path"` Template *string `json:"modelfile"` Options *Options `json:"options"` }
ShowModelRequestBuilder represents the model creation API request.
type StatusResponse ¶
StatusResponse represents the API response for endpoint that return status updates.
type VersionFunc ¶ added in v1.0.4
type VersionFunc func() (*VersionResponse, error)
VersionFunc performs a request to the Ollama API and returns the Ollama server version as a string.
For more information about the request, see the API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md
type VersionResponse ¶ added in v1.0.4
type VersionResponse struct {
Version string `json:"version"`
}
VersionResponse represents the API response for the version endpoint.