ollamasetup

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 17 Imported by: 0

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

View Source
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

func HasModel

func HasModel(models []string, name string) bool

HasModel reports whether name is among models, accepting the implicit ":latest" tag Ollama adds to untagged names.

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 NewManager

func NewManager() *Manager

NewManager returns an empty job manager.

func (*Manager) Detect

func (m *Manager) Detect(ctx context.Context, baseURL string) Status

Detect reports whether Ollama is installed, answering at baseURL, and which models it has.

func (*Manager) Get

func (m *Manager) Get(id string) (Job, bool)

Get returns a snapshot of a job.

func (*Manager) Install

func (m *Manager) Install(id string) (Job, error)

Install runs the install option id when it is runnable on this machine.

func (*Manager) ListModels

func (m *Manager) ListModels(ctx context.Context, baseURL string) ([]string, error)

ListModels returns the names of the models present in Ollama.

func (*Manager) Pull

func (m *Manager) Pull(baseURL, model string) (Job, error)

Pull starts downloading model into Ollama through POST /api/pull and returns the job tracking it.

func (*Manager) Start

func (m *Manager) Start() error

Start launches the Ollama server in the background, detached from Pando's process group so it keeps running after Pando exits.

func (*Manager) WaitRunning

func (m *Manager) WaitRunning(ctx context.Context, baseURL string) bool

WaitRunning polls baseURL until Ollama answers or ctx expires.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL