api

package
v0.0.0-...-f6d5bc3 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHost = "0.0.0.0:11434"

Variables

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

Functions

This section is empty.

Types

type Client

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

func ClientFromEnvironment

func ClientFromEnvironment() (*Client, error)

func (*Client) Copy

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

func (*Client) Create

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

func (*Client) Delete

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

func (*Client) ExecutePlugin

func (c *Client) ExecutePlugin(ctx context.Context, req *ExecutePluginRequest) (map[string]interface{}, error)

ExecutePlugin executes a plugin and returns the results.

func (*Client) Generate

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

func (*Client) Heartbeat

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

func (*Client) List

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

func (*Client) LoadPlugin

func (c *Client) LoadPlugin(ctx context.Context, req *LoadPluginRequest) error

LoadPlugin loads a plugin into the system.

func (*Client) Pull

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

func (*Client) Push

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

func (*Client) Show

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

func (*Client) UnloadPlugin

func (c *Client) UnloadPlugin(ctx context.Context, req *UnloadPluginRequest) error

UnloadPlugin unloads a plugin from the system.

type CopyRequest

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

type CreateProgressFunc

type CreateProgressFunc func(ProgressResponse) error

type CreateRequest

type CreateRequest struct {
	Name   string `json:"name"`
	Path   string `json:"path"`
	Stream *bool  `json:"stream,omitempty"`
}

type DeleteRequest

type DeleteRequest struct {
	Name string `json:"name"`
}

type Duration

type Duration struct {
	time.Duration
}

func (*Duration) UnmarshalJSON

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

type EmbeddingRequest

type EmbeddingRequest struct {
	Model  string `json:"model"`
	Prompt string `json:"prompt"`

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

type EmbeddingResponse

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

type ExecutePluginRequest

type ExecutePluginRequest struct {
	PluginName string                 `json:"plugin_name"`
	Inputs     map[string]interface{} `json:"inputs"`
}

type ExecutePluginResponse

type ExecutePluginResponse struct {
	Outputs map[string]interface{} `json:"outputs"`
	Success bool                   `json:"success"`
	Error   string                 `json:"error,omitempty"`
}

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"`

	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"`

	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 (*GenerateResponse) Summary

func (r *GenerateResponse) Summary()

type GenerateResponseFunc

type GenerateResponseFunc func(GenerateResponse) error

type ListResponse

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

type LoadPluginRequest

type LoadPluginRequest struct {
	PluginName string                 `json:"plugin_name"`
	Config     map[string]interface{} `json:"config"`
}

type ModelResponse

type ModelResponse struct {
	Name       string    `json:"name"`
	ModifiedAt time.Time `json:"modified_at"`
	Size       int64     `json:"size"`
	Digest     string    `json:"digest"`
}

type Options

type Options struct {
	Runner

	// 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"`
}

func DefaultOptions

func DefaultOptions() Options

func (*Options) FromMap

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

type ProgressResponse

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 {
	Name     string `json:"name"`
	Insecure bool   `json:"insecure,omitempty"`
	Username string `json:"username"`
	Password string `json:"password"`
	Stream   *bool  `json:"stream,omitempty"`
}

type PushProgressFunc

type PushProgressFunc func(ProgressResponse) error

type PushRequest

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

type Runner

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"`
	EmbeddingOnly      bool    `json:"embedding_only,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

type ShowRequest struct {
	Name string `json:"name"`
}

type ShowResponse

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"`
}

type StatusError

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

func (StatusError) Error

func (e StatusError) Error() string

type TokenResponse

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

type UnloadPluginRequest

type UnloadPluginRequest struct {
	PluginName string `json:"plugin_name"`
}

Jump to

Keyboard shortcuts

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