ollama

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

ollama implements an API client for ollama https://github.com/ollama/ollama/blob/main/docs/api.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatDuration

type ChatDuration time.Duration

type ChatOpt

type ChatOpt func(*reqChatCompletion) error

func OptFormatJSON

func OptFormatJSON() ChatOpt

OptFormatJSON sets the output to be JSON. it's also important to instruct the model to use JSON in the prompt.

func OptImage

func OptImage(r io.Reader) ChatOpt

OptImage adds an image to the chat completion request

func OptSeed

func OptSeed(v int) ChatOpt

OptSeed sets the seed for the chat completion request

func OptStream

func OptStream(callback func(string)) ChatOpt

OptStream sets the callback to use for chat completion in streaming mode

func OptTemperature

func OptTemperature(v int) ChatOpt

OptTemperature sets deterministic output

type ChatStatus

type ChatStatus struct {
	Response           string `json:"response,omitempty"`
	Context            []int  `json:"context,omitempty"`
	PromptTokens       int    `json:"prompt_eval_count,omitempty"`
	ResponseTokens     int    `json:"total_eval_count,omitempty"`
	LoadDurationNs     int64  `json:"load_duration,omitempty"`
	PromptDurationNs   int64  `json:"prompt_eval_duration,omitempty"`
	ResponseDurationNs int64  `json:"response_eval_duration,omitempty"`
	TotalDurationNs    int64  `json:"total_duration,omitempty"`
}

func (ChatStatus) String

func (m ChatStatus) String() string

type Client

type Client struct {
	*client.Client
}

func New

func New(endPoint string, opts ...client.ClientOpt) (*Client, error)

func (*Client) ChatGenerate

func (c *Client) ChatGenerate(ctx context.Context, model, prompt string, opts ...ChatOpt) (ChatStatus, error)

Generate a response, given a model and a prompt

func (*Client) CopyModel

func (c *Client) CopyModel(source, destination string) error

Copy a local model by name

func (*Client) CreateModel

func (c *Client) CreateModel(ctx context.Context, name, modelfile string) error

Create a new model with a name and contents of the Modelfile

func (*Client) DeleteModel

func (c *Client) DeleteModel(name string) error

Delete a local model by name

func (*Client) Generate added in v1.0.10

func (o *Client) Generate(ctx context.Context, model agent.Model, context []agent.Context, opts ...agent.Opt) (*agent.Response, error)

Generate a response from a text message

func (*Client) ListModels

func (c *Client) ListModels() ([]Model, error)

List local models

func (*Client) Models added in v1.0.10

func (o *Client) Models(context.Context) ([]agent.Model, error)

Return all the models and their capabilities

func (*Client) Name added in v1.0.10

func (*Client) Name() string

Return the agent name

func (*Client) PullModel

func (c *Client) PullModel(ctx context.Context, name string) error

Pull a remote model locally

func (*Client) ShowModel

func (c *Client) ShowModel(name string) (ModelShow, error)

Show model details

func (*Client) UserPrompt added in v1.0.10

func (o *Client) UserPrompt(v string) agent.Context

Create a user prompt

type Model

type Model struct {
	Name       string       `json:"name"`
	Model      string       `json:"model"`
	ModifiedAt time.Time    `json:"modified_at"`
	Size       int64        `json:"size"`
	Digest     string       `json:"digest"`
	Details    ModelDetails `json:"details"`
}

Model is a docker image of a ollama model

func (Model) String

func (m Model) String() string

type ModelDetails

type ModelDetails struct {
	ParentModel       string   `json:"parent_model,omitempty"`
	Format            string   `json:"format"`
	Family            string   `json:"family"`
	Families          []string `json:"families"`
	ParameterSize     string   `json:"parameter_size"`
	QuantizationLevel string   `json:"quantization_level"`
}

ModelDetails are the details of the model

func (ModelDetails) String

func (m ModelDetails) String() string

type ModelShow

type ModelShow struct {
	File       string       `json:"modelfile"`
	Parameters string       `json:"parameters"`
	Template   string       `json:"template"`
	Details    ModelDetails `json:"details"`
}

ModelShow provides details of the docker image

func (ModelShow) String

func (m ModelShow) String() string

Jump to

Keyboard shortcuts

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