Documentation
¶
Overview ¶
Package ollamasetup backs the Remembrances step of the first-run setup assistant: it detects a local Ollama installation, installs or starts it on request, and pulls embedding models through the Ollama HTTP API while reporting progress.
Long operations (install, pull) run as in-memory jobs polled by the client, so they survive the HTTP request that started them and work the same in a browser tab and in the desktop webview.
Index ¶
- Constants
- func HasModel(models []string, name string) bool
- type InstallOption
- type Job
- type Manager
- func (m *Manager) Detect(ctx context.Context, baseURL string) Status
- func (m *Manager) Get(id string) (Job, bool)
- func (m *Manager) Install(id string) (Job, error)
- func (m *Manager) ListModels(ctx context.Context, baseURL string) ([]string, error)
- func (m *Manager) Pull(baseURL, model string) (Job, error)
- func (m *Manager) Start() error
- func (m *Manager) WaitRunning(ctx context.Context, baseURL string) bool
- type Status
Constants ¶
const ( DownloadURL = "https://ollama.com/download" LinuxInstallCmd = "curl -fsSL https://ollama.com/install.sh | sh" BrewInstallCmd = "brew install ollama" WingetInstallCmd = "winget install --id Ollama.Ollama -e --accept-source-agreements --accept-package-agreements" DockerInstallCmd = "docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama" )
Download pages and command lines shown by the assistant.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type InstallOption ¶
type InstallOption struct {
ID string `json:"id"`
Label string `json:"label"`
Command string `json:"command,omitempty"`
URL string `json:"url,omitempty"`
// Recommended marks the option the assistant highlights.
Recommended bool `json:"recommended"`
// Runnable is true when Pando can execute Command itself (the tool is on
// PATH and needs no interactive password prompt).
Runnable bool `json:"runnable"`
// Reason explains why Runnable is false.
Reason string `json:"reason,omitempty"`
}
InstallOption is one way of installing Ollama on the current OS.
type Job ¶
type Job struct {
ID string `json:"id"`
Kind string `json:"kind"`
Target string `json:"target"`
State string `json:"state"` // running | done | error
Status string `json:"status,omitempty"`
Completed int64 `json:"completed"`
Total int64 `json:"total"`
Output []string `json:"output,omitempty"`
Error string `json:"error,omitempty"`
StartedAt time.Time `json:"startedAt"`
EndedAt time.Time `json:"endedAt,omitempty"`
}
Job is a long-running install or pull operation.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager tracks jobs. The zero value is not usable; call NewManager.
func (*Manager) Detect ¶
Detect reports whether Ollama is installed, answering at baseURL, and which models it has.
func (*Manager) ListModels ¶
ListModels returns the names of the models present in Ollama.
func (*Manager) Pull ¶
Pull starts downloading model into Ollama through POST /api/pull and returns the job tracking it.
type Status ¶
type Status struct {
OS string `json:"os"`
BaseURL string `json:"baseUrl"`
Installed bool `json:"installed"`
BinaryPath string `json:"binaryPath,omitempty"`
Running bool `json:"running"`
Version string `json:"version,omitempty"`
Models []string `json:"models"`
InstallOptions []InstallOption `json:"installOptions"`
// CanStart is true when Ollama is installed but not answering and Pando
// knows how to launch it.
CanStart bool `json:"canStart"`
}
Status is the Ollama state reported to the assistant.