ollama

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ollama implements the llm.Provider contract against the Ollama /api/chat endpoint. Stdlib-only.

Ollama uses NDJSON streaming (one JSON object per line) rather than SSE. Tool support requires a model that advertises function calling and Ollama 0.4+. Tool calls don't carry server-assigned IDs, so we mint synthetic ones for the engine; on the wire to Ollama, tool_result messages are sent without IDs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Provider)

Option configures a Provider.

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL points the client at a non-default Ollama host.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient swaps the underlying http.Client.

type Provider

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

Provider is an Ollama /api/chat client.

func New

func New(opts ...Option) (*Provider, error)

New constructs a Provider. OLLAMA_HOST overrides the default origin (http://localhost:11434).

func (*Provider) Stream

func (p *Provider) Stream(ctx context.Context, req llm.Request) (<-chan llm.Event, error)

Stream sends req to /api/chat with stream=true and forwards events onto the returned channel.

Jump to

Keyboard shortcuts

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