server

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: 41 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 CopyModelHandler

func CopyModelHandler(c *gin.Context)

func CreateManifest

func CreateManifest(name string, cfg *LayerReader, layers []*Layer) error

func CreateModel

func CreateModel(ctx context.Context, name string, path string, fn func(resp api.ProgressResponse)) error

func CreateModelHandler

func CreateModelHandler(c *gin.Context)

func DeleteModel

func DeleteModel(name string) error

func DeleteModelHandler

func DeleteModelHandler(c *gin.Context)

func EmbeddingHandler

func EmbeddingHandler(c *gin.Context)

func GenerateHandler

func GenerateHandler(c *gin.Context)

func GetBlobsPath

func GetBlobsPath(digest string) (string, error)

func GetManifestPath

func GetManifestPath() (string, error)

func GetModelInfo

func GetModelInfo(name string) (*api.ShowResponse, 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 ListModelsHandler

func ListModelsHandler(c *gin.Context)

func LoadPluginHandler

func LoadPluginHandler(c *gin.Context)

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(api.ProgressResponse)) error

func PullModelHandler

func PullModelHandler(c *gin.Context)

func PushModel

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

func PushModelHandler

func PushModelHandler(c *gin.Context)

func SaveLayers

func SaveLayers(layers []*LayerReader, fn func(resp api.ProgressResponse), force bool) error

func Serve

func Serve(ln net.Listener, allowOrigins []string) error

func ShowModelHandler

func ShowModelHandler(c *gin.Context)

func ShowModelfile

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

Types

type AuthRedirect

type AuthRedirect struct {
	Realm   string
	Service string
	Scope   string
}

func ParseAuthRedirectString

func ParseAuthRedirectString(authStr string) AuthRedirect

func (AuthRedirect) URL

func (r AuthRedirect) URL() (*url.URL, error)

type ConfigV2

type ConfigV2 struct {
	ModelFormat string `json:"model_format"`
	ModelFamily string `json:"model_family"`
	ModelType   string `json:"model_type"`
	FileType    string `json:"file_type"`
	RootFS      RootFS `json:"rootfs"`

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

type Layer

type Layer struct {
	MediaType string `json:"mediaType"`
	Digest    string `json:"digest"`
	Size      int64  `json:"size"`
	From      string `json:"from,omitempty"`
}

type LayerReader

type LayerReader struct {
	Layer
	io.Reader
}

func CreateLayer

func CreateLayer(f io.ReadSeeker) (*LayerReader, error)

CreateLayer creates a Layer object from a given file

func GetLayerWithBufferFromLayer

func GetLayerWithBufferFromLayer(layer *Layer) (*LayerReader, error)

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 Model

type Model struct {
	Name          string `json:"name"`
	ShortName     string
	ModelPath     string
	OriginalModel string
	AdapterPaths  []string
	Template      string
	System        string
	License       []string
	Digest        string
	Options       map[string]interface{}
}

func GetModel

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

func (*Model) Prompt

func (m *Model) Prompt(request api.GenerateRequest) (string, error)

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

type ProgressWriter

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

func (*ProgressWriter) Write

func (pw *ProgressWriter) Write(b []byte) (int, error)

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 SignatureData

type SignatureData struct {
	Method string
	Path   string
	Data   []byte
}

func (SignatureData) Bytes

func (s SignatureData) Bytes() []byte

Bytes returns a byte slice of the data to sign for the request

func (SignatureData) Sign

func (s SignatureData) Sign(rawKey []byte) (string, error)

SignData takes a SignatureData object and signs it with a raw private key

Jump to

Keyboard shortcuts

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