server

package
v0.0.0-...-51a14f9 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 32 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 CopyModel

func CopyModel(src, dest string) error

func DeleteModel

func DeleteModel(name string) error

func FixBlobs

func FixBlobs(dir string) error

fixBlobs walks the provided dir and replaces ("-") to (":") in the file prefix. (e.g. sha256-1234 -> sha256:1234)

func GetBlobsPath

func GetBlobsPath(digest string) (string, error)

func GetManifestPath

func GetManifestPath() (string, error)

func GetSHA256Digest

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 PruneDirectory

func PruneDirectory(path string) error

func PruneLayers

func PruneLayers() error

func PullModel

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

func PushModel

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

func ShowModelfile

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

func WriteManifest

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

Types

type ConfigV2

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

func (c *ConfigV2) SetFileType(fileType string)

func (*ConfigV2) SetModelFamily

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

func (*ConfigV2) SetModelFormat

func (c *ConfigV2) SetModelFormat(format string)

func (*ConfigV2) SetModelType

func (c *ConfigV2) SetModelType(modelType string)

type Layer

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

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

func NewLayerFromLayer

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

func (*Layer) Commit

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

type Layers

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

func (*Layers) Add

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

func (*Layers) Replace

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

type ManifestV2

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

func GetManifest

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

func (*ManifestV2) GetTotalSize

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

type Message

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

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

func (*Model) IsEmbedding

func (m *Model) IsEmbedding() bool

type ModelPath

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

func ParseModelPath

func ParseModelPath(name string) ModelPath

func (ModelPath) BaseURL

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

func (ModelPath) GetFullTagname

func (mp ModelPath) GetFullTagname() string

func (ModelPath) GetManifestPath

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

func (mp ModelPath) GetNamespaceRepository() string

func (ModelPath) GetShortTagname

func (mp ModelPath) GetShortTagname() string

func (ModelPath) Validate

func (mp ModelPath) Validate() 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 RegistryOptions

type RegistryOptions struct {
	Insecure bool
	Username string
	Password string
	Token    string
}

type RootFS

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

type TokenResponse

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