Method RunAsync
- Namespace
- IntentSharp.Catalog
- Assembly
- IntentSharp.Catalog.dll
RunAsync<T>(string, object?, CancellationToken)
Runs the intent and returns a verified T. The shape must be able to produce
T: string for text; the primitive's type (date also as DateTime,
datetime as DateTime or DateTimeOffset, lists as arrays or list interfaces); the registered type
or a base of it for clr shapes; JsonNode (or JsonObject/JsonArray) for schema shapes. Any shape
can be run as JsonNode. Otherwise IntentShapeMismatchException is thrown before any model call.
public Task<AIResult<T>> RunAsync<T>(string name, object? input, CancellationToken cancellationToken = default)
Parameters
namestringinputobjectcancellationTokenCancellationToken
Returns
- Task<AIResult<T>>
Type Parameters
T
Remarks
When the client runs a trial of the document the definition was loaded from (Trials)
and this call is one it samples, the candidate version's definition of the intent also runs, after this one, with
the same input and as T, and the trial records how the two verified values compared. The
result is still this version's, with the candidate's tokens added to Usage, its time to
Elapsed and its attempts after this version's in Attempts. The
candidate is checked and run under the guardrail sets this version names as well as its own, so it never runs
under weaker enforcement. A candidate that is refused, fails, throws or cannot be read changes nothing else; only
cancellation stops the call.
Exceptions
- GuardrailPolicyException
The Tool checkpoint refused the intent; no model is called.
RunAsync(string, object?, CancellationToken)
Runs the intent and returns the verified result as JSON, whatever its shape (typed shapes are serialized with SerializerOptions).
public Task<AIResult<JsonNode>> RunAsync(string name, object? input, CancellationToken cancellationToken = default)
Parameters
namestringinputobjectcancellationTokenCancellationToken
Returns
- Task<AIResult<JsonNode>>
Remarks
A call an intent trial samples also runs the candidate version's definition and compares the two values as JSON, as RunAsync<T>(string, object?, CancellationToken) describes; the result is this version's.
Exceptions
- GuardrailPolicyException
The Tool checkpoint refused the intent; no model is called.