llama

package
v0.82.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LlamaProviderID       = "llama.cpp"
	DefaultLlamaServerURL = "http://127.0.0.1:8080"
)

Variables

This section is empty.

Functions

func FindHuggingFaceToken

func FindHuggingFaceToken() string

FindHuggingFaceToken follows Hugging Face's environment and cache path precedence. Unreadable files are skipped so an optional token never blocks local llama.cpp use.

func FormatLlamaBytes

func FormatLlamaBytes(bytes float64) string

func LlamaInferenceURL

func LlamaInferenceURL(serverURL string) (string, error)

func NormalizeLlamaServerURL

func NormalizeLlamaServerURL(value string) (string, error)

Types

type HuggingFaceClient

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

HuggingFaceClient owns the catalog transport configuration used by the llama.cpp extension. Search and detail results are detached typed values.

func NewHuggingFaceClient

func NewHuggingFaceClient(
	token string,
	options ...HuggingFaceClientOptions,
) (*HuggingFaceClient, error)

func (*HuggingFaceClient) Details

func (*HuggingFaceClient) Search

func (c *HuggingFaceClient) Search(
	ctx context.Context,
	query string,
) ([]HuggingFaceModel, error)

type HuggingFaceClientOptions

type HuggingFaceClientOptions struct {
	BaseURL    string
	HTTPClient llm.HTTPDoer
	Timeout    time.Duration
}

type HuggingFaceGating

type HuggingFaceGating string
const (
	HuggingFaceGatingNone   HuggingFaceGating = ""
	HuggingFaceGatingAuto   HuggingFaceGating = "auto"
	HuggingFaceGatingManual HuggingFaceGating = "manual"
)

type HuggingFaceHTTPError

type HuggingFaceHTTPError struct {
	StatusCode int
	Message    string
}

func (*HuggingFaceHTTPError) Error

func (e *HuggingFaceHTTPError) Error() string

type HuggingFaceModel

type HuggingFaceModel struct {
	ID        string `json:"id"`
	Downloads int64  `json:"downloads"`
}

type HuggingFaceModelDetails

type HuggingFaceModelDetails struct {
	ID            string
	Gating        HuggingFaceGating
	Quantizations []HuggingFaceQuantization
}

type HuggingFaceQuantization

type HuggingFaceQuantization struct {
	Name string
	Size *int64
}

type LlamaClient

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

LlamaClient is a context-aware client for the llama.cpp router management API. It owns no model state; callers publish returned catalogs explicitly.

func NewLlamaClient

func NewLlamaClient(
	serverURL string,
	apiKey string,
	options ...LlamaClientOptions,
) (*LlamaClient, error)

func (*LlamaClient) Download

func (c *LlamaClient) Download(
	ctx context.Context,
	model string,
) error

func (*LlamaClient) DownloadAndWait

func (c *LlamaClient) DownloadAndWait(
	ctx context.Context,
	model string,
	onProgress func(LlamaProgress),
) ([]LlamaModelInfo, error)

func (*LlamaClient) List

func (c *LlamaClient) List(
	ctx context.Context,
	options LlamaListOptions,
) ([]LlamaModelInfo, error)

func (*LlamaClient) Load

func (c *LlamaClient) Load(ctx context.Context, model string) error

func (*LlamaClient) LoadAndWait

func (c *LlamaClient) LoadAndWait(
	ctx context.Context,
	model string,
	onProgress func(LlamaProgress),
) (LlamaModelInfo, error)

func (*LlamaClient) ServerURL

func (c *LlamaClient) ServerURL() string

func (*LlamaClient) Unload

func (c *LlamaClient) Unload(ctx context.Context, model string) error

func (*LlamaClient) UnloadAndWait

func (c *LlamaClient) UnloadAndWait(
	ctx context.Context,
	model string,
) error

func (*LlamaClient) Watch

func (c *LlamaClient) Watch(
	ctx context.Context,
	onEvent func(LlamaModelEvent),
) error

type LlamaClientOptions

type LlamaClientOptions struct {
	HTTPClient   llm.HTTPDoer
	Timeout      time.Duration
	PollInterval time.Duration
}

type LlamaHTTPError

type LlamaHTTPError struct {
	StatusCode int
	Message    string
}

LlamaHTTPError preserves the management endpoint status and server message.

func (*LlamaHTTPError) Error

func (e *LlamaHTTPError) Error() string

type LlamaListOptions

type LlamaListOptions struct {
	Reload bool
}

type LlamaModelArchitecture

type LlamaModelArchitecture struct {
	InputModalities  []string `json:"input_modalities,omitempty"`
	OutputModalities []string `json:"output_modalities,omitempty"`
}

type LlamaModelEvent

type LlamaModelEvent struct {
	Model string          `json:"model"`
	Event string          `json:"event"`
	Data  json.RawMessage `json:"data,omitempty"`
}

LlamaModelEvent is one router SSE event. Data stays raw at the transport boundary and is decoded into operation-specific state by wait methods.

type LlamaModelInfo

type LlamaModelInfo struct {
	ID           string                 `json:"id"`
	Aliases      []string               `json:"aliases,omitempty"`
	Status       LlamaModelStatus       `json:"status"`
	Architecture LlamaModelArchitecture `json:"architecture,omitempty"`
	Source       string                 `json:"source,omitempty"`
	Meta         LlamaModelMeta         `json:"meta,omitempty"`
}

LlamaModelInfo is the canonical management-plane model record.

type LlamaModelLifecycle

type LlamaModelLifecycle string

LlamaModelLifecycle is the router-owned lifecycle state for one model.

const (
	LlamaModelUnloaded    LlamaModelLifecycle = "unloaded"
	LlamaModelLoading     LlamaModelLifecycle = "loading"
	LlamaModelLoaded      LlamaModelLifecycle = "loaded"
	LlamaModelDownloading LlamaModelLifecycle = "downloading"
	LlamaModelSleeping    LlamaModelLifecycle = "sleeping"
)

type LlamaModelMeta

type LlamaModelMeta struct {
	ContextWindow      *int   `json:"n_ctx,omitempty"`
	TrainingContext    *int   `json:"n_ctx_train,omitempty"`
	Size               *int64 `json:"size,omitempty"`
	QuantizationFormat string `json:"ftype,omitempty"`
}

type LlamaModelStatus

type LlamaModelStatus struct {
	Value    LlamaModelLifecycle              `json:"value"`
	Args     []string                         `json:"args,omitempty"`
	Failed   bool                             `json:"failed,omitempty"`
	ExitCode *int                             `json:"exit_code,omitempty"`
	Progress map[string]LlamaTransferProgress `json:"progress,omitempty"`
}

LlamaModelStatus is the typed lifecycle projection returned by llama.cpp.

type LlamaProgress

type LlamaProgress struct {
	Message string
	Ratio   *float64
	Detail  string
}

LlamaProgress is a detached user-facing progress update.

type LlamaProviderController

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

LlamaProviderController owns the atomic catalog projection shared by the provider refresh path and the interactive management flow.

func CreateLlamaProvider

func CreateLlamaProvider(
	options ...LlamaProviderOptions,
) (*LlamaProviderController, error)

func (*LlamaProviderController) Provider

func (c *LlamaProviderController) Provider() *llm.Provider

func (*LlamaProviderController) SetCatalog

func (c *LlamaProviderController) SetCatalog(
	catalog []LlamaModelInfo,
	serverURL string,
) error

type LlamaProviderOptions

type LlamaProviderOptions struct {
	HTTPClient   llm.HTTPDoer
	Timeout      time.Duration
	PollInterval time.Duration
}

type LlamaTransferProgress

type LlamaTransferProgress struct {
	Done  float64 `json:"done"`
	Total float64 `json:"total"`
}

LlamaTransferProgress reports byte progress for one downloaded artifact.

Jump to

Keyboard shortcuts

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