Class IntentRuntime
- Namespace
- IntentSharp.Catalog
- Assembly
- IntentSharp.Catalog.dll
Runs catalog intents by name. Each call reads the definition from Current, so a reload
takes effect on the next call, and turns it into one IntentClient request: the shape picks the call
(text, a primitive, a registered .NET type, or a JSON schema defined at run time), and the definition supplies the
attempts, judge, provider, model, timeout, output limit, examples, output requirements, system instructions, memory
opt-out, rules, schema checks and named validators. Every request is tagged intent.name, intent.version
and intent.source (plus the definition's own tags), so logs and memory entries say which version decided.
public sealed class IntentRuntime
- Inheritance
-
objectIntentRuntime
- Inherited Members
-
object.Equals(object)object.Equals(object, object)object.GetHashCode()object.GetType()object.ReferenceEquals(object, object)object.ToString()
- Extension Methods
Remarks
Rules and schema violations are validator issues: the model sees them on its next attempt, exactly like a caller's validator. Not found, invalid, disabled and shape mismatch are exceptions thrown before any model call; so are a named validator or clr type that is not registered. Thread-safe; register one per application.
The first time the runtime runs a definition object it checks it with the same rules as a file and keeps a private copy; every run of that object reads the copy. Changing a definition in place after it has run therefore changes nothing: publish a new snapshot (edit the file, or Replace(IntentDefinition)) instead.
Constructors
- IntentRuntime(IntentClient, IIntentCatalog, IIntentValidatorRegistry?, IIntentTypeRegistry?, ILogger<IntentRuntime>?)
Creates a runtime that runs the definitions in
catalogthroughclient.
Properties
- Catalog
The catalog definitions are read from.
Methods
- AsAmbient()
Makes this runtime ambient for the current async flow (see IntentScope).
- Describe(string)
A copy of the current definition named
name: the checked copy runs use once the definition has run, otherwise the catalog's definition. Throws IntentNotFoundException when there is none.
- RunAsync(string, object?, CancellationToken)
Runs the intent and returns the verified result as JSON, whatever its shape (typed shapes are serialized with SerializerOptions).
- RunAsync<T>(string, object?, CancellationToken)
Runs the intent and returns a verified
T. The shape must be able to produceT:stringfor text; the primitive's type (datealso asDateTime,datetimeasDateTimeorDateTimeOffset, lists as arrays or list interfaces); the registered type or a base of it for clr shapes;JsonNode(orJsonObject/JsonArray) for schema shapes. Any shape can be run asJsonNode. Otherwise IntentShapeMismatchException is thrown before any model call. Adateordatetimeasked for asDateTimestill runs as its declared type (DateOnlyorDateTimeOffset), so the model is asked for that format and the rules check its text; the verified value is then read asDateTimewith SerializerOptions.