server

package
v0.0.0-...-e65ccaf Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CapabilityCompletion = Capability("completion")
	CapabilityTools      = Capability("tools")
	CapabilityInsert     = Capability("insert")
)
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")
	ErrInvalidDigestFormat = errors.New("invalid digest format")
)
View Source
var ErrMaxQueue = errors.New("server busy, please try again.  maximum pending requests exceeded")

Functions

func CopyModel

func CopyModel(src, dst model.Name) error

func GetBlobsPath

func GetBlobsPath(digest string) (string, error)

func GetManifestPath

func GetManifestPath() (string, error)

func GetModelInfo

func GetModelInfo(req api.ShowRequest) (*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 Manifests

func Manifests(continueOnError bool) (map[model.Name]*Manifest, error)

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 PushModel

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

func Serve

func Serve(ln net.Listener) error

func WriteManifest

func WriteManifest(name model.Name, config Layer, layers []Layer) error

Types

type ByDuration

type ByDuration []*runnerRef

func (ByDuration) Len

func (a ByDuration) Len() int

func (ByDuration) Less

func (a ByDuration) Less(i, j int) bool

func (ByDuration) Swap

func (a ByDuration) Swap(i, j int)

type Capability

type Capability string

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

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) Open

func (l *Layer) Open() (io.ReadSeekCloser, error)

func (*Layer) Remove

func (l *Layer) Remove() error

type LlmRequest

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

type Manifest

type Manifest struct {
	SchemaVersion int     `json:"schemaVersion"`
	MediaType     string  `json:"mediaType"`
	Config        Layer   `json:"config"`
	Layers        []Layer `json:"layers"`
	// contains filtered or unexported fields
}

func GetManifest

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

func ParseNamedManifest

func ParseNamedManifest(n model.Name) (*Manifest, error)

func (*Manifest) Remove

func (m *Manifest) Remove() error

func (*Manifest) RemoveLayers

func (m *Manifest) RemoveLayers() error

func (*Manifest) Size

func (m *Manifest) Size() (size int64)

type Model

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

	Template *template.Template
}

func GetModel

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

func (*Model) CheckCapabilities

func (m *Model) CheckCapabilities(caps ...Capability) error

CheckCapabilities checks if the model has the specified capabilities returning an error describing any missing or unknown capabilities

func (*Model) String

func (m *Model) String() string

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 RootFS

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

type Scheduler

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

func InitScheduler

func InitScheduler(ctx context.Context) *Scheduler

func (*Scheduler) GetRunner

func (s *Scheduler) GetRunner(c context.Context, model *Model, opts api.Options, sessionDuration *api.Duration) (chan *runnerRef, chan error)

context must be canceled to decrement ref count and release the runner

func (*Scheduler) Run

func (s *Scheduler) Run(ctx context.Context)

Returns immediately, spawns go routines for the scheduler which will shutdown when ctx is done

type Server

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

func (*Server) ChatHandler

func (s *Server) ChatHandler(c *gin.Context)

func (*Server) CopyHandler

func (s *Server) CopyHandler(c *gin.Context)

func (*Server) CreateBlobHandler

func (s *Server) CreateBlobHandler(c *gin.Context)

func (*Server) CreateHandler

func (s *Server) CreateHandler(c *gin.Context)

func (*Server) DeleteHandler

func (s *Server) DeleteHandler(c *gin.Context)

func (*Server) EmbedHandler

func (s *Server) EmbedHandler(c *gin.Context)

func (*Server) EmbeddingsHandler

func (s *Server) EmbeddingsHandler(c *gin.Context)

func (*Server) GenerateHandler

func (s *Server) GenerateHandler(c *gin.Context)

func (*Server) GenerateRoutes

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

func (*Server) HeadBlobHandler

func (s *Server) HeadBlobHandler(c *gin.Context)

func (*Server) ListHandler

func (s *Server) ListHandler(c *gin.Context)

func (*Server) PsHandler

func (s *Server) PsHandler(c *gin.Context)

func (*Server) PullHandler

func (s *Server) PullHandler(c *gin.Context)

func (*Server) PushHandler

func (s *Server) PushHandler(c *gin.Context)

func (*Server) ShowHandler

func (s *Server) ShowHandler(c *gin.Context)

Jump to

Keyboard shortcuts

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