Documentation
¶
Index ¶
- Constants
- Variables
- func CopyModel(src, dst model.Name) error
- func GetBlobsPath(digest string) (string, error)
- func GetManifestPath() (string, error)
- func GetModelInfo(req api.ShowRequest) (*api.ShowResponse, error)
- func GetSHA256Digest(r io.Reader) (string, int64)
- func Manifests(continueOnError bool) (map[model.Name]*Manifest, error)
- func PruneDirectory(path string) error
- func PruneLayers() error
- func PullModel(ctx context.Context, name string, regOpts *registryOptions, ...) error
- func PushModel(ctx context.Context, name string, regOpts *registryOptions, ...) error
- func Serve(ln net.Listener) error
- func WriteManifest(name model.Name, config Layer, layers []Layer) error
- type ByDurationAndName
- type ConfigV2
- type FunctionNameMap
- type HarmonyEvent
- type HarmonyEventContentEmitted
- type HarmonyEventHeaderComplete
- type HarmonyEventMessageEnd
- type HarmonyEventMessageStart
- type HarmonyHeader
- type HarmonyMessageHandler
- type HarmonyParser
- type HarmonyToolCallAccumulator
- type Layer
- type LlmRequest
- type Manifest
- type Model
- type ModelPath
- type RootFS
- type Scheduler
- type Server
- func (s *Server) ChatHandler(c *gin.Context)
- func (s *Server) CopyHandler(c *gin.Context)
- func (s *Server) CreateBlobHandler(c *gin.Context)
- func (s *Server) CreateHandler(c *gin.Context)
- func (s *Server) DeleteHandler(c *gin.Context)
- func (s *Server) EmbedHandler(c *gin.Context)
- func (s *Server) EmbeddingsHandler(c *gin.Context)
- func (s *Server) GenerateHandler(c *gin.Context)
- func (s *Server) GenerateRoutes(rc *ollama.Registry) (http.Handler, error)
- func (s *Server) HeadBlobHandler(c *gin.Context)
- func (s *Server) ListHandler(c *gin.Context)
- func (s *Server) PsHandler(c *gin.Context)
- func (s *Server) PullHandler(c *gin.Context)
- func (s *Server) PushHandler(c *gin.Context)
- func (s *Server) ShowHandler(c *gin.Context)
Constants ¶
const ( DefaultRegistry = "registry.ollama.ai" DefaultNamespace = "library" DefaultTag = "latest" DefaultProtocolScheme = "https" )
Variables ¶
var ( ErrInvalidImageFormat = errors.New("invalid image format") ErrInvalidDigestFormat = errors.New("invalid digest format") ErrInvalidProtocol = errors.New("invalid protocol scheme") ErrInsecureProtocol = errors.New("insecure protocol http") ErrModelPathInvalid = errors.New("invalid model path") )
var ErrMaxQueue = errors.New("server busy, please try again. maximum pending requests exceeded")
Functions ¶
func GetBlobsPath ¶
func GetManifestPath ¶
func GetModelInfo ¶
func GetModelInfo(req api.ShowRequest) (*api.ShowResponse, error)
func GetSHA256Digest ¶
GetSHA256Digest returns the SHA256 hash of a given buffer and returns it, and the size of buffer
func PruneDirectory ¶
func PruneLayers ¶
func PruneLayers() error
Types ¶
type ByDurationAndName ¶ added in v0.6.6
type ByDurationAndName []*runnerRef
func (ByDurationAndName) Len ¶ added in v0.6.6
func (a ByDurationAndName) Len() int
func (ByDurationAndName) Less ¶ added in v0.6.6
func (a ByDurationAndName) Less(i, j int) bool
func (ByDurationAndName) Swap ¶ added in v0.6.6
func (a ByDurationAndName) Swap(i, j int)
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 FunctionNameMap ¶ added in v0.11.5
type FunctionNameMap struct {
// contains filtered or unexported fields
}
FunctionNameMap maps a user-specified function name to a valid function name for harmony (which look like TypeScript identifiers). This is needed to transform user-specified function names, which might contain characters that are not allowed in TypeScript identifiers
func NewFunctionNameMap ¶ added in v0.11.5
func NewFunctionNameMap() *FunctionNameMap
func (*FunctionNameMap) ConvertAndAdd ¶ added in v0.11.5
func (m *FunctionNameMap) ConvertAndAdd(userFunctionName string) string
func (*FunctionNameMap) OriginalFromConverted ¶ added in v0.11.5
func (m *FunctionNameMap) OriginalFromConverted(harmonyFunctionName string) string
OriginalFromConverted looks up the reverse-mapping of a previously-converted user->harmony function name. To unmap reliably, the mapping must exist, as the conversion process is not reversible without the appropriate state
type HarmonyEvent ¶ added in v0.11.1
type HarmonyEvent interface {
// contains filtered or unexported methods
}
type HarmonyEventContentEmitted ¶ added in v0.11.1
type HarmonyEventContentEmitted struct {
Content string
}
type HarmonyEventHeaderComplete ¶ added in v0.11.1
type HarmonyEventHeaderComplete struct {
Header HarmonyHeader
}
type HarmonyEventMessageEnd ¶ added in v0.11.1
type HarmonyEventMessageEnd struct{}
type HarmonyEventMessageStart ¶ added in v0.11.1
type HarmonyEventMessageStart struct{}
type HarmonyHeader ¶ added in v0.11.1
type HarmonyMessageHandler ¶ added in v0.11.1
type HarmonyMessageHandler struct {
// contains filtered or unexported fields
}
HarmonyMessageHandler processes harmony events and accumulates content appropriately. This is a higher level interface that maps harmony concepts into ollama concepts
func NewHarmonyMessageHandler ¶ added in v0.11.1
func NewHarmonyMessageHandler() *HarmonyMessageHandler
NewHarmonyMessageHandler creates a new message handler
func (*HarmonyMessageHandler) AddContent ¶ added in v0.11.1
func (h *HarmonyMessageHandler) AddContent(content string, toolParser *HarmonyToolCallAccumulator) (string, string, string)
AddContent processes the content and returns the content, thinking, and tool content. content and thinking are already fully parsed, but tool content still needs to be passed to the tool parser
func (*HarmonyMessageHandler) CreateToolParser ¶ added in v0.11.1
func (h *HarmonyMessageHandler) CreateToolParser() *HarmonyToolCallAccumulator
type HarmonyParser ¶ added in v0.11.1
type HarmonyParser struct {
MessageStartTag string
MessageEndTag string
HeaderEndTag string
// contains filtered or unexported fields
}
func (*HarmonyParser) AddContent ¶ added in v0.11.1
func (s *HarmonyParser) AddContent(content string) []HarmonyEvent
func (*HarmonyParser) AddImplicitStart ¶ added in v0.11.1
func (s *HarmonyParser) AddImplicitStart()
func (*HarmonyParser) AddImplicitStartOrPrefill ¶ added in v0.11.1
func (s *HarmonyParser) AddImplicitStartOrPrefill(lastMessage *api.Message)
type HarmonyToolCallAccumulator ¶ added in v0.11.1
type HarmonyToolCallAccumulator struct {
// contains filtered or unexported fields
}
func (*HarmonyToolCallAccumulator) Add ¶ added in v0.11.1
func (a *HarmonyToolCallAccumulator) Add(content string)
func (*HarmonyToolCallAccumulator) Content ¶ added in v0.11.1
func (a *HarmonyToolCallAccumulator) Content() string
func (*HarmonyToolCallAccumulator) Drain ¶ added in v0.11.1
func (a *HarmonyToolCallAccumulator) Drain() (*string, string)
func (*HarmonyToolCallAccumulator) SetToolName ¶ added in v0.11.1
func (a *HarmonyToolCallAccumulator) SetToolName(toolName 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 NewLayerFromLayer ¶
type LlmRequest ¶ added in v0.1.33
type LlmRequest struct {
// contains filtered or unexported fields
}
type Manifest ¶ added in v0.1.35
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 (*Manifest) RemoveLayers ¶ added in v0.1.42
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]any
Messages []api.Message
Template *template.Template
}
func (*Model) Capabilities ¶ added in v0.6.4
func (m *Model) Capabilities() []model.Capability
Capabilities returns the capabilities that the model supports
func (*Model) CheckCapabilities ¶ added in v0.2.2
func (m *Model) CheckCapabilities(want ...model.Capability) error
CheckCapabilities checks if the model has the specified capabilities returning an error describing any missing or unknown capabilities
type ModelPath ¶
type ModelPath struct {
ProtocolScheme string
Registry string
Namespace string
Repository string
Tag string
}
func ParseModelPath ¶
func (ModelPath) GetFullTagname ¶
func (ModelPath) GetManifestPath ¶
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 (ModelPath) GetShortTagname ¶
type Scheduler ¶ added in v0.1.33
type Scheduler struct {
// contains filtered or unexported fields
}
func InitScheduler ¶ added in v0.1.33
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ChatHandler ¶ added in v0.1.33
func (*Server) CopyHandler ¶ added in v0.3.8
func (*Server) CreateBlobHandler ¶ added in v0.1.33
func (*Server) CreateHandler ¶ added in v0.3.8
func (*Server) DeleteHandler ¶ added in v0.3.8
func (*Server) EmbedHandler ¶ added in v0.2.6
func (*Server) EmbeddingsHandler ¶ added in v0.1.33
func (*Server) GenerateHandler ¶ added in v0.1.33
func (*Server) GenerateRoutes ¶
func (*Server) HeadBlobHandler ¶ added in v0.1.33
func (*Server) ListHandler ¶ added in v0.3.8
func (*Server) PullHandler ¶ added in v0.3.8
func (*Server) PushHandler ¶ added in v0.3.8
func (*Server) ShowHandler ¶ added in v0.3.8
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
cache/blob
Package blob implements a content-addressable disk cache for blobs and manifests.
|
Package blob implements a content-addressable disk cache for blobs and manifests. |
|
client/ollama
Package ollama provides a client for interacting with an Ollama registry which pushes and pulls model manifests and layers as defined by the ollama.com/manifest.
|
Package ollama provides a client for interacting with an Ollama registry which pushes and pulls model manifests and layers as defined by the ollama.com/manifest. |
|
internal/stringsx
Package stringsx provides additional string manipulation functions that aren't in the standard library's strings package or go4.org/mem.
|
Package stringsx provides additional string manipulation functions that aren't in the standard library's strings package or go4.org/mem. |
|
internal/syncs
Package syncs provides synchronization primitives.
|
Package syncs provides synchronization primitives. |
|
manifest
Package manifest provides documentation for the Ollama manifest format.
|
Package manifest provides documentation for the Ollama manifest format. |
|
registry
Package registry implements an http.Handler for handling local Ollama API model management requests.
|
Package registry implements an http.Handler for handling local Ollama API model management requests. |