ollama

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ollama manages the Ollama process lifecycle for Cortex.

It provides health checking, automatic startup, model detection, and model pulling — all used by the TUI, CLI, and app initialization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles checking, starting, and provisioning Ollama.

func NewManager

func NewManager(baseURL string) *Manager

NewManager creates a new Ollama manager. If baseURL is empty, defaults to http://localhost:11434.

func (*Manager) BaseURL

func (m *Manager) BaseURL() string

BaseURL returns the configured Ollama base URL.

func (*Manager) EnsureRunning

func (m *Manager) EnsureRunning(ctx context.Context) error

EnsureRunning checks if Ollama is running, starts it if not, and waits for readiness.

func (*Manager) HasModel

func (m *Manager) HasModel(ctx context.Context, model string) (bool, error)

HasModel checks if a specific model is available in Ollama.

func (*Manager) IsRunning

func (m *Manager) IsRunning(ctx context.Context) bool

IsRunning checks whether Ollama is responding at the configured URL.

func (*Manager) PullModel

func (m *Manager) PullModel(ctx context.Context, model string, progressFn func(string)) error

PullModel runs `ollama pull <model>` and reports progress via the callback. The progressFn is called with status strings; it may be nil.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start launches `ollama serve` as a background process. It does not wait for readiness — use WaitReady after Start.

func (*Manager) StartedByUs

func (m *Manager) StartedByUs() bool

StartedByUs returns true if this manager started the Ollama process.

func (*Manager) WaitReady

func (m *Manager) WaitReady(ctx context.Context, timeout time.Duration) error

WaitReady polls the health endpoint until Ollama responds or timeout expires.

Jump to

Keyboard shortcuts

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