Documentation
¶
Overview ¶
Package ollama provides a minimal Ollama REST client for Prism.
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"`
Tools []Tool `json:"tools,omitempty"`
Stream bool `json:"stream"`
// Format constrains the response to a JSON schema (Ollama structured
// outputs). Pass a marshalled JSON schema object.
Format json.RawMessage `json:"format,omitempty"`
Options *Options `json:"options,omitempty"`
}
ChatRequest is the payload for POST /api/chat.
type ChatResponse ¶
type ChatResponse struct {
Model string `json:"model"`
Message Message `json:"message"`
Done bool `json:"done"`
// Token counts (present when Ollama is configured to return them).
PromptEvalCount int `json:"prompt_eval_count"`
EvalCount int `json:"eval_count"`
// Total generation duration in nanoseconds.
TotalDuration int64 `json:"total_duration"`
}
ChatResponse is the non-streaming response from POST /api/chat.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a lightweight Ollama REST client.
func NewClient ¶
NewClient creates a Client targeting host. If host is empty it defaults to http://127.0.0.1:11434.
func (*Client) Chat ¶
func (c *Client) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
Chat sends a non-streaming chat request and returns the full response.
func (*Client) ListModels ¶
ListModels returns the model tags available on the local Ollama server.
type Message ¶
type Message struct {
Role string `json:"role"` // system | user | assistant | tool
Content string `json:"content"`
ToolName string `json:"tool_name,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}
Message is one turn in an Ollama conversation.
type Options ¶
type Options struct {
// Temperature is a pointer so an explicit 0 (deterministic sampling) is
// serialized instead of being dropped by omitempty.
Temperature *float64 `json:"temperature,omitempty"`
// NumCtx is the context window size in tokens passed to the model.
NumCtx int `json:"num_ctx,omitempty"`
NumPredict int `json:"num_predict,omitempty"`
}
Options maps to Ollama model parameters.
type Tool ¶ added in v0.1.14
type Tool struct {
Type string `json:"type"`
Function ToolFunction `json:"function"`
}
type ToolCall ¶ added in v0.1.14
type ToolCall struct {
Function ToolCallFunction `json:"function"`
}