Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatRequest ¶
type ChatRequest struct { Model string `json:"model"` Messages []*Message `json:"messages"` Format *string `json:"format,omitempty"` Options *RequestOptions `json:"options,omitempty"` Stream *bool `json:"stream,omitempty"` KeepAlive *int `json:"keep_alive,omitempty"` Tools []Tool `json:"tools,omitempty"` }
ChatRequest represents a request to the chat endpoint
type ChatResponse ¶
type ChatResponse struct { Message Message `json:"message"` Model string `json:"model"` CreatedAt time.Time `json:"created_at"` Done bool `json:"done"` DoneReason string `json:"done_reason,omitempty"` TotalDuration int64 `json:"total_duration"` LoadDuration int64 `json:"load_duration"` PromptEvalCount int `json:"prompt_eval_count"` EvalCount int `json:"eval_count"` EvalDuration int64 `json:"eval_duration"` }
ChatResponse represents a response from the chat endpoint
type ClientOption ¶
type ClientOption func(*OllamaClient)
ClientOption is a function that modifies the client
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
WithBaseURL sets the base URL for the client
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient sets the HTTP client for the API client
type Message ¶
type Message struct { Role Role `json:"role"` Content string `json:"content"` Images []string `json:"images,omitempty"` ToolCalls []ToolCall `json:"tool_calls,omitempty"` }
Message represents a chat message
type OllamaClient ¶
type OllamaClient struct {
// contains filtered or unexported fields
}
OllamaClient represents an Ollama API client
func NewClient ¶
func NewClient(options ...ClientOption) *OllamaClient
NewClient creates a new Ollama client
func (*OllamaClient) Chat ¶
func (c *OllamaClient) Chat(ctx context.Context, req *ChatRequest) (*ChatResponse, error)
Chat sends a chat request to the Ollama API
func (*OllamaClient) ChatStream ¶
func (c *OllamaClient) ChatStream(ctx context.Context, req *ChatRequest, handler func(*ChatResponse) error) (*ChatResponse, error)
ChatStream sends a chat request and handles streaming responses
type RequestOptions ¶
type RequestOptions struct { NumKeep *int `json:"num_keep,omitempty"` Seed *int `json:"seed,omitempty"` NumPredict *int `json:"num_predict,omitempty"` TopK *int `json:"top_k,omitempty"` TopP *float64 `json:"top_p,omitempty"` MinP *float64 `json:"min_p,omitempty"` TFSZ *float64 `json:"tfs_z,omitempty"` TypicalP *float64 `json:"typical_p,omitempty"` RepeatLastN *int `json:"repeat_last_n,omitempty"` Temperature *float64 `json:"temperature,omitempty"` RepeatPenalty *float64 `json:"repeat_penalty,omitempty"` PresencePenalty *float64 `json:"presence_penalty,omitempty"` FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"` Mirostat *int `json:"mirostat,omitempty"` MirostatTau *float64 `json:"mirostat_tau,omitempty"` MirostatEta *float64 `json:"mirostat_eta,omitempty"` PenalizeNewline *bool `json:"penalize_newline,omitempty"` Stop []string `json:"stop,omitempty"` Numa *bool `json:"numa,omitempty"` NumCtx *int `json:"num_ctx,omitempty"` NumBatch *int `json:"num_batch,omitempty"` NumGPU *int `json:"num_gpu,omitempty"` MainGPU *int `json:"main_gpu,omitempty"` LowVRAM *bool `json:"low_vram,omitempty"` F16KV *bool `json:"f16_kv,omitempty"` LogitsAll *bool `json:"logits_all,omitempty"` VocabOnly *bool `json:"vocab_only,omitempty"` UseMMap *bool `json:"use_mmap,omitempty"` UseMLock *bool `json:"use_mlock,omitempty"` NumThread *int `json:"num_thread,omitempty"` }
RequestOptions represents optional parameters for the request
type Tool ¶
type Tool struct { Type string `json:"type"` Function ToolFunction `json:"function"` }
Tool represents a function tool that the model can use
type ToolCall ¶
type ToolCall struct {
Function ToolCallFunction `json:"function"`
}
ToolCall represents a tool call made by the model
type ToolCallFunction ¶
type ToolCallFunction struct { Name string `json:"name"` Arguments json.RawMessage `json:"arguments"` }
ToolCallFunction represents the function being called
type ToolFunction ¶
type ToolFunction struct { Name string `json:"name"` Description string `json:"description"` Parameters json.RawMessage `json:"parameters"` }
ToolFunction represents a function that can be called by the model