server

package
v0.1.29 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRegistry       = "registry.ollama.ai"
	DefaultNamespace      = "library"
	DefaultTag            = "latest"
	DefaultProtocolScheme = "https"
)

Variables

View Source
var (
	ErrInvalidImageFormat = errors.New("invalid image format")
	ErrInvalidProtocol    = errors.New("invalid protocol scheme")
	ErrInsecureProtocol   = errors.New("insecure protocol http")
)

Functions

func ChatHandler added in v0.1.14

func ChatHandler(c *gin.Context)

func ChatPrompt added in v0.1.25

func ChatPrompt(tmpl string, messages []api.Message, window int, encode func(string) ([]int, error)) (string, error)

ChatPrompt builds up a prompt from a series of messages, truncating based on context window size

func CopyModel added in v0.0.12

func CopyModel(src, dest string) error

func CopyModelHandler added in v0.0.12

func CopyModelHandler(c *gin.Context)

func CreateBlobHandler added in v0.1.10

func CreateBlobHandler(c *gin.Context)

func CreateModel added in v0.0.6

func CreateModel(ctx context.Context, name, modelFileDir string, commands []parser.Command, fn func(resp api.ProgressResponse)) error

func CreateModelHandler added in v0.0.11

func CreateModelHandler(c *gin.Context)

func DeleteModel added in v0.0.11

func DeleteModel(name string) error

func DeleteModelHandler added in v0.0.11

func DeleteModelHandler(c *gin.Context)

func EmbeddingsHandler added in v0.1.28

func EmbeddingsHandler(c *gin.Context)

func GenerateHandler added in v0.0.11

func GenerateHandler(c *gin.Context)

func GetBlobsPath added in v0.0.6

func GetBlobsPath(digest string) (string, error)

func GetManifestPath added in v0.0.6

func GetManifestPath() (string, error)

func GetModelInfo added in v0.0.18

func GetModelInfo(req api.ShowRequest) (*api.ShowResponse, error)

func GetSHA256Digest added in v0.0.6

func GetSHA256Digest(r io.Reader) (string, int64)

GetSHA256Digest returns the SHA256 hash of a given buffer and returns it, and the size of buffer

func HeadBlobHandler added in v0.1.10

func HeadBlobHandler(c *gin.Context)

func ListModelsHandler added in v0.0.11

func ListModelsHandler(c *gin.Context)

func Prompt added in v0.1.18

func Prompt(tmpl, system, prompt, response string, generate bool) (string, error)

Prompt renders a prompt from a template. If generate is set to true, the response and parts of the template following it are not rendered

func PruneDirectory added in v0.1.1

func PruneDirectory(path string) error

func PruneLayers added in v0.0.19

func PruneLayers() error

func PullModel added in v0.0.6

func PullModel(ctx context.Context, name string, regOpts *registryOptions, fn func(api.ProgressResponse)) error

func PullModelHandler added in v0.0.11

func PullModelHandler(c *gin.Context)

func PushModel added in v0.0.6

func PushModel(ctx context.Context, name string, regOpts *registryOptions, fn func(api.ProgressResponse)) error

func PushModelHandler added in v0.0.11

func PushModelHandler(c *gin.Context)

func Serve

func Serve(ln net.Listener) error

func ShowModelHandler added in v0.0.18

func ShowModelHandler(c *gin.Context)

func ShowModelfile added in v0.0.18

func ShowModelfile(model *Model) (string, error)

func WriteManifest added in v0.1.14

func WriteManifest(name string, config *Layer, layers []*Layer) error

Types

type ConfigV2 added in v0.0.6

type ConfigV2 struct {
	ModelFormat   string   `json:"model_format"`
	ModelFamily   string   `json:"model_family"`
	ModelFamilies []string `json:"model_families"`
	ModelType     string   `json:"model_type"`
	FileType      string   `json:"file_type"`

	// required by spec
	Architecture string `json:"architecture"`
	OS           string `json:"os"`
	RootFS       RootFS `json:"rootfs"`
}

func (*ConfigV2) SetFileType added in v0.1.14

func (c *ConfigV2) SetFileType(fileType string)

func (*ConfigV2) SetModelFamily added in v0.1.14

func (c *ConfigV2) SetModelFamily(families ...string)

func (*ConfigV2) SetModelFormat added in v0.1.14

func (c *ConfigV2) SetModelFormat(format string)

func (*ConfigV2) SetModelType added in v0.1.14

func (c *ConfigV2) SetModelType(modelType string)

type Layer added in v0.0.6

type Layer struct {
	MediaType string `json:"mediaType"`
	Digest    string `json:"digest"`
	Size      int64  `json:"size"`
	From      string `json:"from,omitempty"`
	// contains filtered or unexported fields
}

func NewLayer added in v0.1.14

func NewLayer(r io.Reader, mediatype string) (*Layer, error)

func NewLayerFromLayer added in v0.1.14

func NewLayerFromLayer(digest, mediatype, from string) (*Layer, error)

func (*Layer) Commit added in v0.1.14

func (l *Layer) Commit() (bool, error)

type Layers added in v0.1.14

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

func (*Layers) Add added in v0.1.14

func (ls *Layers) Add(layer *Layer)

func (*Layers) Replace added in v0.1.14

func (ls *Layers) Replace(layer *Layer)

type ManifestV2 added in v0.0.6

type ManifestV2 struct {
	SchemaVersion int      `json:"schemaVersion"`
	MediaType     string   `json:"mediaType"`
	Config        *Layer   `json:"config"`
	Layers        []*Layer `json:"layers"`
}

func GetManifest added in v0.0.6

func GetManifest(mp ModelPath) (*ManifestV2, string, error)

func (*ManifestV2) GetTotalSize added in v0.0.6

func (m *ManifestV2) GetTotalSize() (total int64)

type Message added in v0.1.22

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type Model

type Model struct {
	Name           string `json:"name"`
	Config         ConfigV2
	ShortName      string
	ModelPath      string
	ParentModel    string
	AdapterPaths   []string
	ProjectorPaths []string
	Template       string
	System         string
	License        []string
	Digest         string
	Size           int64
	Options        map[string]interface{}
	Messages       []Message
}

func GetModel added in v0.0.6

func GetModel(name string) (*Model, error)

func (*Model) IsEmbedding added in v0.1.26

func (m *Model) IsEmbedding() bool

type ModelPath added in v0.0.6

type ModelPath struct {
	ProtocolScheme string
	Registry       string
	Namespace      string
	Repository     string
	Tag            string
}

func ParseModelPath added in v0.0.6

func ParseModelPath(name string) ModelPath

func (ModelPath) BaseURL added in v0.0.16

func (mp ModelPath) BaseURL() *url.URL

func (ModelPath) GetFullTagname added in v0.0.6

func (mp ModelPath) GetFullTagname() string

func (ModelPath) GetManifestPath added in v0.0.6

func (mp ModelPath) GetManifestPath() (string, error)

GetManifestPath returns the path to the manifest file for the given model path, it is up to the caller to create the directory if it does not exist.

func (ModelPath) GetNamespaceRepository added in v0.0.6

func (mp ModelPath) GetNamespaceRepository() string

func (ModelPath) GetShortTagname added in v0.0.6

func (mp ModelPath) GetShortTagname() string

func (ModelPath) Validate added in v0.1.13

func (mp ModelPath) Validate() error

type RootFS added in v0.0.6

type RootFS struct {
	Type    string   `json:"type"`
	DiffIDs []string `json:"diff_ids"`
}

type Server added in v0.1.17

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

func (*Server) GenerateRoutes added in v0.1.17

func (s *Server) GenerateRoutes() http.Handler

Jump to

Keyboard shortcuts

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