v0.1.28 Latest Latest

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 19 Imported by: 0




This section is empty.


View Source
var ErrInvalidOpts = fmt.Errorf("invalid options")


func FormatParams added in v0.1.13

func FormatParams(params map[string][]string) (map[string]interface{}, error)

FormatParams converts specified parameter options to their correct types


type ChatRequest added in v0.1.14

type ChatRequest struct {
	Model     string    `json:"model"`
	Messages  []Message `json:"messages"`
	Stream    *bool     `json:"stream,omitempty"`
	Format    string    `json:"format"`
	KeepAlive *Duration `json:"keep_alive,omitempty"`

	Options map[string]interface{} `json:"options"`

type ChatResponse added in v0.1.14

type ChatResponse struct {
	Model     string    `json:"model"`
	CreatedAt time.Time `json:"created_at"`
	Message   Message   `json:"message"`

	Done bool `json:"done"`


type ChatResponseFunc added in v0.1.14

type ChatResponseFunc func(ChatResponse) error

type Client

type Client struct {
	// contains filtered or unexported fields

func ClientFromEnvironment added in v0.1.2

func ClientFromEnvironment() (*Client, error)

func (*Client) Chat added in v0.1.14

func (c *Client) Chat(ctx context.Context, req *ChatRequest, fn ChatResponseFunc) error

func (*Client) Copy added in v0.0.12

func (c *Client) Copy(ctx context.Context, req *CopyRequest) error

func (*Client) Create added in v0.0.6

func (c *Client) Create(ctx context.Context, req *CreateRequest, fn CreateProgressFunc) error

func (*Client) CreateBlob added in v0.1.10

func (c *Client) CreateBlob(ctx context.Context, digest string, r io.Reader) error

func (*Client) Delete added in v0.0.11

func (c *Client) Delete(ctx context.Context, req *DeleteRequest) error

func (*Client) Embeddings added in v0.1.19

func (c *Client) Embeddings(ctx context.Context, req *EmbeddingRequest) (*EmbeddingResponse, error)

func (*Client) Generate

func (c *Client) Generate(ctx context.Context, req *GenerateRequest, fn GenerateResponseFunc) error

func (*Client) Heartbeat added in v0.0.13

func (c *Client) Heartbeat(ctx context.Context) error

func (*Client) List added in v0.0.6

func (c *Client) List(ctx context.Context) (*ListResponse, error)

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, req *PullRequest, fn PullProgressFunc) error

func (*Client) Push added in v0.0.6

func (c *Client) Push(ctx context.Context, req *PushRequest, fn PushProgressFunc) error

func (*Client) Show added in v0.0.18

func (c *Client) Show(ctx context.Context, req *ShowRequest) (*ShowResponse, error)

func (*Client) Version added in v0.1.14

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

type CopyRequest added in v0.0.12

type CopyRequest struct {
	Source      string `json:"source"`
	Destination string `json:"destination"`

type CreateProgressFunc added in v0.0.6

type CreateProgressFunc func(ProgressResponse) error

type CreateRequest added in v0.0.6

type CreateRequest struct {
	Model     string `json:"model"`
	Path      string `json:"path"`
	Modelfile string `json:"modelfile"`
	Stream    *bool  `json:"stream,omitempty"`

	// Name is deprecated, see Model
	Name string `json:"name"`

type DeleteRequest added in v0.0.11

type DeleteRequest struct {
	Model string `json:"model"`

	// Name is deprecated, see Model
	Name string `json:"name"`

type Duration added in v0.0.13

type Duration struct {

func (*Duration) UnmarshalJSON added in v0.0.13

func (d *Duration) UnmarshalJSON(b []byte) (err error)

type EmbeddingRequest added in v0.0.14

type EmbeddingRequest struct {
	Model     string    `json:"model"`
	Prompt    string    `json:"prompt"`
	KeepAlive *Duration `json:"keep_alive,omitempty"`

	Options map[string]interface{} `json:"options"`

type EmbeddingResponse added in v0.0.14

type EmbeddingResponse struct {
	Embedding []float64 `json:"embedding"`

type GenerateRequest

type GenerateRequest struct {
	Model     string      `json:"model"`
	Prompt    string      `json:"prompt"`
	System    string      `json:"system"`
	Template  string      `json:"template"`
	Context   []int       `json:"context,omitempty"`
	Stream    *bool       `json:"stream,omitempty"`
	Raw       bool        `json:"raw,omitempty"`
	Format    string      `json:"format"`
	KeepAlive *Duration   `json:"keep_alive,omitempty"`
	Images    []ImageData `json:"images,omitempty"`

	Options map[string]interface{} `json:"options"`

type GenerateResponse

type GenerateResponse struct {
	Model     string    `json:"model"`
	CreatedAt time.Time `json:"created_at"`
	Response  string    `json:"response"`

	Done    bool  `json:"done"`
	Context []int `json:"context,omitempty"`


type GenerateResponseFunc

type GenerateResponseFunc func(GenerateResponse) error

type ImageData added in v0.1.15

type ImageData []byte

type ListResponse added in v0.0.6

type ListResponse struct {
	Models []ModelResponse `json:"models"`

type Message added in v0.1.14

type Message struct {
	Role    string      `json:"role"` // one of ["system", "user", "assistant"]
	Content string      `json:"content"`
	Images  []ImageData `json:"images,omitempty"`

type Metrics added in v0.1.14

type Metrics struct {
	TotalDuration      time.Duration `json:"total_duration,omitempty"`
	LoadDuration       time.Duration `json:"load_duration,omitempty"`
	PromptEvalCount    int           `json:"prompt_eval_count,omitempty"`
	PromptEvalDuration time.Duration `json:"prompt_eval_duration,omitempty"`
	EvalCount          int           `json:"eval_count,omitempty"`
	EvalDuration       time.Duration `json:"eval_duration,omitempty"`

func (*Metrics) Summary added in v0.1.14

func (m *Metrics) Summary()

type ModelDetails added in v0.1.15

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

type ModelResponse added in v0.0.18

type ModelResponse 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,omitempty"`

type Options added in v0.0.3

type Options struct {

	// Predict options used at runtime
	NumKeep          int      `json:"num_keep,omitempty"`
	Seed             int      `json:"seed,omitempty"`
	NumPredict       int      `json:"num_predict,omitempty"`
	TopK             int      `json:"top_k,omitempty"`
	TopP             float32  `json:"top_p,omitempty"`
	TFSZ             float32  `json:"tfs_z,omitempty"`
	TypicalP         float32  `json:"typical_p,omitempty"`
	RepeatLastN      int      `json:"repeat_last_n,omitempty"`
	Temperature      float32  `json:"temperature,omitempty"`
	RepeatPenalty    float32  `json:"repeat_penalty,omitempty"`
	PresencePenalty  float32  `json:"presence_penalty,omitempty"`
	FrequencyPenalty float32  `json:"frequency_penalty,omitempty"`
	Mirostat         int      `json:"mirostat,omitempty"`
	MirostatTau      float32  `json:"mirostat_tau,omitempty"`
	MirostatEta      float32  `json:"mirostat_eta,omitempty"`
	PenalizeNewline  bool     `json:"penalize_newline,omitempty"`
	Stop             []string `json:"stop,omitempty"`

Options specified in GenerateRequest, if you add a new option here add it to the API docs also

func DefaultOptions added in v0.0.3

func DefaultOptions() Options

func (*Options) FromMap added in v0.0.14

func (opts *Options) FromMap(m map[string]interface{}) error

type ProgressResponse added in v0.0.7

type ProgressResponse struct {
	Status    string `json:"status"`
	Digest    string `json:"digest,omitempty"`
	Total     int64  `json:"total,omitempty"`
	Completed int64  `json:"completed,omitempty"`

type PullProgressFunc

type PullProgressFunc func(ProgressResponse) error

type PullRequest

type PullRequest struct {
	Model    string `json:"model"`
	Insecure bool   `json:"insecure,omitempty"`
	Username string `json:"username"`
	Password string `json:"password"`
	Stream   *bool  `json:"stream,omitempty"`

	// Name is deprecated, see Model
	Name string `json:"name"`

type PushProgressFunc added in v0.0.6

type PushProgressFunc func(ProgressResponse) error

type PushRequest added in v0.0.6

type PushRequest struct {
	Model    string `json:"model"`
	Insecure bool   `json:"insecure,omitempty"`
	Username string `json:"username"`
	Password string `json:"password"`
	Stream   *bool  `json:"stream,omitempty"`

	// Name is deprecated, see Model
	Name string `json:"name"`

type Runner added in v0.1.4

type Runner struct {
	UseNUMA            bool    `json:"numa,omitempty"`
	NumCtx             int     `json:"num_ctx,omitempty"`
	NumBatch           int     `json:"num_batch,omitempty"`
	NumGQA             int     `json:"num_gqa,omitempty"`
	NumGPU             int     `json:"num_gpu,omitempty"`
	MainGPU            int     `json:"main_gpu,omitempty"`
	LowVRAM            bool    `json:"low_vram,omitempty"`
	F16KV              bool    `json:"f16_kv,omitempty"`
	LogitsAll          bool    `json:"logits_all,omitempty"`
	VocabOnly          bool    `json:"vocab_only,omitempty"`
	UseMMap            bool    `json:"use_mmap,omitempty"`
	UseMLock           bool    `json:"use_mlock,omitempty"`
	RopeFrequencyBase  float32 `json:"rope_frequency_base,omitempty"`
	RopeFrequencyScale float32 `json:"rope_frequency_scale,omitempty"`
	NumThread          int     `json:"num_thread,omitempty"`

Runner options which must be set when the model is loaded into memory

type ShowRequest added in v0.0.18

type ShowRequest struct {
	Model    string `json:"model"`
	System   string `json:"system"`
	Template string `json:"template"`

	Options map[string]interface{} `json:"options"`

	// Name is deprecated, see Model
	Name string `json:"name"`

type ShowResponse added in v0.0.18

type ShowResponse struct {
	License    string       `json:"license,omitempty"`
	Modelfile  string       `json:"modelfile,omitempty"`
	Parameters string       `json:"parameters,omitempty"`
	Template   string       `json:"template,omitempty"`
	System     string       `json:"system,omitempty"`
	Details    ModelDetails `json:"details,omitempty"`
	Messages   []Message    `json:"messages,omitempty"`

type StatusError added in v0.0.3

type StatusError struct {
	StatusCode   int
	Status       string
	ErrorMessage string `json:"error"`

func (StatusError) Error added in v0.0.3

func (e StatusError) Error() string

type TokenResponse added in v0.0.14

type TokenResponse struct {
	Token string `json:"token"`

Jump to

Keyboard shortcuts

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