Documentation
¶
Overview ¶
Package engine routes completion requests to loaded runtime Instances, applying governor admission and telemetry accounting. It is the single serving funnel shared by the local OpenAI API and the tunnel dispatcher.
Index ¶
- Variables
- type Admitter
- type Engine
- func (e *Engine) Complete(ctx context.Context, req rt.CompletionRequest) (rt.TokenStream, error)
- func (e *Engine) DefaultModel() string
- func (e *Engine) Health(ctx context.Context, model string) (rt.Stats, error)
- func (e *Engine) Models() []*ModelEntry
- func (e *Engine) Register(spec rt.ModelSpec, inst rt.Instance)
- func (e *Engine) SetDefault(id string) error
- func (e *Engine) Stats() *telemetry.Stats
- func (e *Engine) Unregister(id string) *ModelEntry
- func (e *Engine) UnregisterIdle(id string) (*ModelEntry, error)
- func (e *Engine) Usage(id string) (Usage, bool)
- type ModelEntry
- type Usage
Constants ¶
This section is empty.
Variables ¶
var ErrBusy = errors.New("engine: model busy")
ErrBusy is returned by UnregisterIdle when the model has requests in flight (or waiting in admission) and so must not be unloaded.
var ErrModelNotFound = errors.New("engine: model not loaded")
ErrModelNotFound is returned for unknown model ids.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine implements tunnel.Engine and backs localapi.
func (*Engine) Complete ¶
func (e *Engine) Complete(ctx context.Context, req rt.CompletionRequest) (rt.TokenStream, error)
Complete runs one request through admission, the runtime, and telemetry.
func (*Engine) DefaultModel ¶
DefaultModel returns the fallback model id.
func (*Engine) SetDefault ¶ added in v0.3.0
SetDefault names the model used when a request omits one. The model must be loaded — a default pointing at nothing would turn every bare request into a 404.
func (*Engine) Unregister ¶
func (e *Engine) Unregister(id string) *ModelEntry
Unregister removes a model (eviction); callers shut the instance down. Requests in flight on it fail when the instance goes away — use UnregisterIdle when that is not acceptable.
func (*Engine) UnregisterIdle ¶ added in v0.4.0
func (e *Engine) UnregisterIdle(id string) (*ModelEntry, error)
UnregisterIdle removes a model only if nothing is in flight on it. The in-flight check and the removal happen under the same lock the request path takes to route to the model, so a request cannot slip in between: after this returns, either the model is gone and no request holds it, or ErrBusy says a request does. Daemon-initiated unloads (memory admission, idle unload) use this; the operator's explicit unload keeps Unregister's forced semantics.