Documentation
¶
Index ¶
Constants ¶
const (
// Ollama API prefix
APIPrefix = "/api"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatRequest ¶
type ChatRequest struct {
Name string `json:"name"` // Ollama uses 'name' field
Model string `json:"model"` // Also accept 'model' for compatibility
Messages []Message `json:"messages"`
Stream *bool `json:"stream,omitempty"`
KeepAlive string `json:"keep_alive,omitempty"` // Duration like "5m" or "0s" to unload immediately
Options map[string]interface{} `json:"options,omitempty"`
}
ChatRequest is the request for /api/chat
type ChatResponse ¶
type ChatResponse struct {
Model string `json:"model"`
CreatedAt time.Time `json:"created_at"`
Message Message `json:"message,omitempty"`
Done bool `json:"done"`
}
ChatResponse is the response for /api/chat
type DeleteRequest ¶
type DeleteRequest struct {
Name string `json:"name"` // Ollama uses 'name' field
Model string `json:"model"` // Also accept 'model' for compatibility
}
DeleteRequest is the request for DELETE /api/delete
type GenerateRequest ¶
type GenerateRequest struct {
Name string `json:"name"` // Ollama uses 'name' field
Model string `json:"model"` // Also accept 'model' for compatibility
Prompt string `json:"prompt"`
Stream *bool `json:"stream,omitempty"`
KeepAlive string `json:"keep_alive,omitempty"` // Duration like "5m" or "0s" to unload immediately
Options map[string]interface{} `json:"options,omitempty"`
}
GenerateRequest is the request for /api/generate
type GenerateResponse ¶
type GenerateResponse struct {
Model string `json:"model"`
CreatedAt time.Time `json:"created_at"`
Response string `json:"response,omitempty"`
Done bool `json:"done"`
}
GenerateResponse is the response for /api/generate
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements the Ollama API compatibility layer
func NewHandler ¶
func NewHandler(log logging.Logger, modelManager *models.Manager, scheduler *scheduling.Scheduler, allowedOrigins []string) *Handler
NewHandler creates a new Ollama API handler
type ListResponse ¶
type ListResponse struct {
Models []ModelResponse `json:"models"`
}
ListResponse is the response for /api/tags
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 contains model metadata
type ModelResponse ¶
type ModelResponse struct {
Name string `json:"name"`
ModifiedAt time.Time `json:"modified_at"`
Size int64 `json:"size"`
Digest string `json:"digest"`
Details ModelDetails `json:"details"`
}
ModelResponse represents a single model in the list
type PSModel ¶
type PSModel struct {
Name string `json:"name"`
Model string `json:"model"`
Size int64 `json:"size"`
Digest string `json:"digest"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
SizeVram int64 `json:"size_vram,omitempty"`
}
PSModel represents a running model in the ps response
type PullRequest ¶
type PullRequest struct {
Name string `json:"name"` // Ollama uses 'name' field
Model string `json:"model"` // Also accept 'model' for compatibility
Insecure bool `json:"insecure,omitempty"`
Stream *bool `json:"stream,omitempty"`
}
PullRequest is the request for POST /api/pull
type ShowRequest ¶
type ShowRequest struct {
Name string `json:"name"` // Ollama uses 'name' field
Model string `json:"model"` // Also accept 'model' for compatibility
Verbose bool `json:"verbose,omitempty"`
}
ShowRequest is the request for /api/show
type ShowResponse ¶
type ShowResponse struct {
License string `json:"license,omitempty"`
Modelfile string `json:"modelfile,omitempty"`
Parameters string `json:"parameters,omitempty"`
Template string `json:"template,omitempty"`
Details ModelDetails `json:"details,omitempty"`
}
ShowResponse is the response for /api/show