modeldapi

package
v0.32.8 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRoutes

func AddRoutes(mux *http.ServeMux, opts ...Option)

AddRoutes registers modeld observability and safe single-slot control routes. Routes are mounted below /api by the containing server.

Types

type ActiveModel

type ActiveModel struct {
	ModelName  string        `json:"modelName,omitempty" example:"qwen3-8b"`
	Type       string        `json:"type,omitempty" example:"llama"`
	Digest     string        `json:"digest,omitempty" example:"sha256:abcdef"`
	Config     RuntimeConfig `json:"config"`
	Generation uint64        `json:"generation" example:"3"`
}

type CapacityDevice

type CapacityDevice struct {
	Index       int    `json:"index"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Type        string `json:"type,omitempty"`
	MemoryFree  int64  `json:"memoryFree,omitempty"`
	MemoryTotal int64  `json:"memoryTotal,omitempty"`
}

type CapacityInfo

type CapacityInfo struct {
	ModelMaxContext              int              `json:"modelMaxContext"`
	EffectiveContext             int              `json:"effectiveContext"`
	MemoryContextTokens          int              `json:"memoryContextTokens,omitempty"`
	HotContextTokens             int              `json:"hotContextTokens,omitempty"`
	PlannerEffectiveContext      int              `json:"plannerEffectiveContext,omitempty"`
	KVBytesPerToken              int64            `json:"kvBytesPerToken,omitempty"`
	FreeBytes                    int64            `json:"freeBytes,omitempty"`
	WeightsBytes                 int64            `json:"weightsBytes,omitempty"`
	OverheadBytes                int64            `json:"overheadBytes,omitempty"`
	ReservedBytes                int64            `json:"reservedBytes,omitempty"`
	UserLimitBytes               int64            `json:"userLimitBytes,omitempty"`
	MinFreeBytes                 int64            `json:"minFreeBytes,omitempty"`
	HostColdBudgetBytes          int64            `json:"hostColdBudgetBytes,omitempty"`
	UsableBytes                  int64            `json:"usableBytes,omitempty"`
	RequiredBytes                int64            `json:"requiredBytes,omitempty"`
	Clamped                      bool             `json:"clamped,omitempty"`
	Reason                       string           `json:"reason,omitempty"`
	DeviceKind                   string           `json:"deviceKind,omitempty"`
	DeviceID                     string           `json:"deviceId,omitempty"`
	DeviceTotalBytes             int64            `json:"deviceTotalBytes,omitempty"`
	SharedWithDisplay            bool             `json:"sharedWithDisplay,omitempty"`
	RequestedGpuLayers           int              `json:"requestedGpuLayers,omitempty"`
	ResolvedGpuLayers            int              `json:"resolvedGpuLayers,omitempty"`
	SparseAttention              bool             `json:"sparseAttention,omitempty"`
	SlidingWindowAttentionTokens int              `json:"slidingWindowAttentionTokens,omitempty"`
	RuntimeName                  string           `json:"runtimeName,omitempty"`
	RuntimeDigest                string           `json:"runtimeDigest,omitempty"`
	RuntimeSystemInfo            string           `json:"runtimeSystemInfo,omitempty"`
	SupportsGPUOffload           bool             `json:"supportsGpuOffload,omitempty"`
	Devices                      []CapacityDevice `json:"devices,omitempty" openapi_include_type:"modeldapi.CapacityDevice"`
}

type CapacityResponse

type CapacityResponse struct {
	Model LocalModel   `json:"model" openapi_include_type:"modeldapi.LocalModel"`
	Info  CapacityInfo `json:"info" openapi_include_type:"modeldapi.CapacityInfo"`
}

type LocalModel

type LocalModel struct {
	ID              string `json:"id" example:"llama:qwen3-8b"`
	Model           string `json:"model" example:"qwen3-8b"`
	Name            string `json:"name,omitempty" example:"Qwen3 8B"`
	BackendID       string `json:"backendId,omitempty" example:"b7d9e1a3-8f0c-4a7d-9b1e-2f3a4b5c6d7e"`
	BackendName     string `json:"backendName,omitempty" example:"llama"`
	BackendType     string `json:"backendType" example:"llama"`
	Digest          string `json:"digest,omitempty" example:"sha256:abcdef"`
	ContextLength   int    `json:"contextLength,omitempty" example:"8192"`
	MaxOutputTokens int    `json:"maxOutputTokens,omitempty" example:"4096"`
	CanChat         bool   `json:"canChat"`
	CanEmbed        bool   `json:"canEmbed"`
	CanPrompt       bool   `json:"canPrompt"`
	CanStream       bool   `json:"canStream"`
	CanThink        bool   `json:"canThink,omitempty"`
}

LocalModel is the browser-safe identity of a modeld-servable local model. It deliberately omits the backend BaseURL and resolved daemon filesystem path.

type Option

type Option func(*handler)

Option configures modeld routes.

func WithStateReader

func WithStateReader(reader stateReader) Option

WithStateReader enables registry-backed local model listing and capacity diagnostics. The reader is normally the runtime stateservice.

type RuntimeConfig

type RuntimeConfig struct {
	NumCtx                  int       `json:"numCtx,omitempty"`
	HotContextTokens        int       `json:"hotContextTokens,omitempty"`
	PlannerEffectiveContext int       `json:"plannerEffectiveContext,omitempty"`
	NumBatch                int       `json:"numBatch,omitempty"`
	NumThreads              int       `json:"numThreads,omitempty"`
	NumGpuLayers            int       `json:"numGpuLayers,omitempty"`
	TensorSplit             []float32 `json:"tensorSplit,omitempty"`
	FlashAttn               bool      `json:"flashAttn,omitempty"`
	KVCacheType             string    `json:"kvCacheType,omitempty"`
	PromptFormat            string    `json:"promptFormat,omitempty"`
	PromptTemplateDigest    string    `json:"promptTemplateDigest,omitempty"`
	DisableBOS              bool      `json:"disableBOS,omitempty"`
	ReasoningFormat         string    `json:"reasoningFormat,omitempty"`
}

type SlotStatus

type SlotStatus struct {
	OwnerInstanceID string       `json:"ownerInstanceId,omitempty" example:"5f2a23ad-3d9f-46dd-bc21-4c6c2f901e22"`
	Backend         string       `json:"backend,omitempty" example:"llama"`
	State           string       `json:"state,omitempty" example:"Ready"`
	Active          *ActiveModel `json:"active,omitempty" openapi_include_type:"modeldapi.ActiveModel"`
	BusyOperation   string       `json:"busyOperation,omitempty" example:"load"`
	LastError       string       `json:"lastError,omitempty" example:"model does not fit"`
}

type StatusResponse

type StatusResponse struct {
	State              string      `json:"state" example:"running"`
	Available          bool        `json:"available" example:"true"`
	Binary             string      `json:"binary,omitempty" example:"/home/user/.contenox/modeld/v0.1.0/linux-amd64/modeld"`
	Endpoint           string      `json:"endpoint,omitempty" example:"127.0.0.1:42001"`
	Instance           string      `json:"instance,omitempty" example:"5f2a23ad-3d9f-46dd-bc21-4c6c2f901e22"`
	Backend            string      `json:"backend,omitempty" example:"llama"`
	Error              string      `json:"error,omitempty" example:"modeld is not running"`
	RuntimeProtocol    int         `json:"runtimeProtocol" example:"1"`
	MinRuntimeProtocol int         `json:"minRuntimeProtocol" example:"1"`
	Slot               *SlotStatus `json:"slot,omitempty" openapi_include_type:"modeldapi.SlotStatus"`
}

StatusResponse is Beam's curated view of modeld daemon state. It deliberately excludes filesystem paths from ActiveModel; the browser gets logical model identity and slot state, not daemon-local path details.

type UnloadRequest

type UnloadRequest struct {
	ExpectedGeneration *uint64 `json:"expectedGeneration" example:"3"`
}

type UnloadResponse

type UnloadResponse struct {
	Unloaded           bool   `json:"unloaded" example:"true"`
	ExpectedGeneration uint64 `json:"expectedGeneration" example:"3"`
}

Jump to

Keyboard shortcuts

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