Table of Contents

Class ChatModelLease

Namespace
Qavren.Edge.Chat
Assembly
Qavren.Edge.Chat.Onnx.dll

A borrowed model. Exclusive for the duration of one turn - there is no shared-reader mode, because the GenAI C API is not thread safe and a second generator is a second full KV cache. Disposing releases the lease; the Model and Tokenizer are disposed only when the last lease returns after a drop. This is sub-project 2's OnnxSessionLease contract and it exists for the same reason: every ORT GenAI wrapper type is IDisposable with a finalizer, so a dropped-but-undisposed model pins the whole native graph until GC - jetsam bait - while disposing one under a live GenerateNextToken is a native access violation.

public sealed class ChatModelLease : IDisposable
Inheritance
ChatModelLease
Implements
Inherited Members

Properties

Config

The configuration the model was built from, overlay already applied.

Info

What the host knows about the model, as of the moment the lease was taken.

Model

The loaded model. Valid until this lease is disposed and never after.

Tokenizer

Its tokenizer.

Methods

Dispose()

Releases the lease. Idempotent.