Documentation
Table of Contents

Namespace IntentSharp.Specialist

Classes

AIComparisonEvaluator

The AI fit check: asks a model the developer names whether the offer meets the request. It runs as a normal typed call on the client, so it passes the client's checkpoints and counts toward its limits. A failed judge call is a finding that does not fit. A SpecialistRuntime adds it after the other evaluators when AIJudge or an intent's AIJudge is set.

AIFitJudgeOptions

Turns on the AI fit judge and says who judges. Off unless the developer sets AIJudge or an intent's AIJudge. There is no default model: set Model (with Provider when the judge is not the primary provider) or Role.

CatalogContextSource

Sends the application's other intents with every request, as one item of kind Program named ItemName: the name, description and tags of each intent in the catalog except the requested one, in name order. Nothing else of a definition is sent. A change to the catalog changes the item, and so the request hash.

DefinitionComparisonEvaluator

The default fit check, made in code with no model call. An offer fits when its definition keeps the requested intent's name and result shape, keeps every requested rule unchanged (it may add rules), keeps every requested validator name and guardrail set, and, when the offer's RequestHash is set, was provided for this request. The reasons name what differs and never quote a value from an input.

DelegateContextSource

A context source that calls a function of the developer's own.

DocumentContextSource

Sends documents of a core IDocumentStore with every request, one item of kind Document per document, read at its running version: the item's name and reference are the document's id, its text is the document's text, its hash is the version's content hash, and its version property is the version's sequence. A document with no running version sends nothing.

DocumentSpecialistStore

An ISpecialistStore over the state of a core IDocumentStore, so what a SpecialistRuntime knows survives a restart and is shared by every process on the same store. It keeps, per intent and request hash, the ticket and the fit report, per intent the times of the requests, and per intent the held record of the specialist in use (HeldSpecialist). Several runtimes on one store send one request per intent and request hash and share one hourly limit; a restarted runtime waits on the request it recorded instead of sending a new one.

FitContext

What a fit evaluator judges: the request, the ticket, the offer, the client, and RunAsync<T>(object?, CancellationToken), which runs the offered definition on the specialist through the normal pipeline before the offer is in use.

FitFinding

One evaluator's verdict on an offer: whether it fits and, when it does not, why.

FitReport

The verdict on an offer: it fits when every finding fits.

HeldSpecialist

A specialist a SpecialistRuntime put in use, as its ISpecialistStore holds it: the specialist's name, the definition the service returned, how the specialist is reached, the request it answers and the verdict on it. The runtime keeps one per intent while HoldSpecialists is on, replaces it when another specialist is put in use for the intent, and forgets it on RetireAsync(string, CancellationToken).

HeldSpecialistContext

What a When(Func<HeldSpecialistContext, bool>) predicate decides on: the held record and the request being ensured.

HeldSpecialistPolicy

Decides whether an ensure puts a fitting held specialist (HeldSpecialist) in use from the store before it requests or waits. Set it in UseHeld or an intent's UseHeld. The default is Use.

InMemorySpecialistStore

The default ISpecialistStore: everything in memory, for the life of the process. Thread-safe. Intent names are compared ignoring case.

IntentDataContextSource

Sends the requested intent's own result shape and examples with every request, as items of kind Data: result-shape, the shape as an intent file writes it, and examples, the worked examples, when the intent has any.

KeepPreviousContext

What a When(Func<KeepPreviousContext, bool>) predicate decides on: the request the specialist in use answers, the new one, and where the intent stands.

KeepPreviousPolicy

Decides whether calls keep running on the specialist in use while a changed request is requested, waited for and judged in the background. Set it in KeepPrevious or an intent's KeepPrevious. The default is Never: callers wait for the new specialist.

NotFitContext

What a INotFitHandler decides on: the request, the ticket, the offer that did not fit and the verdict.

ProbeCase

One input to try an offered specialist on, with the output expected for it when there is one.

ProbeCaseEvaluator

A fit check that runs cases the developer supplies through the normal pipeline on the offered specialist. The offer fits when the share of cases that pass reaches the required pass rate, all of them by default. A case passes when its result succeeds and, when it names an expected output, the result agrees with it. Each case is a model call on the specialist, so keep the cases few. Add it to FitEvaluators or to an intent's own list.

SpecialistChangeHandler

An opt-in environment change handler that refreshes specialists when a document they depend on changes. On a Document change it finds, in each runtime it watches, the intents that runtime has requested a specialist for and not retired whose definition was loaded from the changed document, or whose DocumentContextSource reads it, and starts RefreshAsync(string, CancellationToken) for each. The handler returns once the refreshes have started: it does not wait for any specialist, so the client's handler timeout never runs while a specialist is awaited.

SpecialistClientBuilderExtensions

Declares the specialist settings and subjects on a client builder.

SpecialistContextItem

One piece of context sent with a SpecialistRequest, so the specialist service knows where and how the intent is used. Set the parts that apply: text, JSON content, a reference, a hash and string properties are all optional. Every part takes part in the request hash.

SpecialistContextSources

Small context sources for text the developer writes: a description of the program and of how data flows through it.

SpecialistGuardrailException

Thrown instead of sending a request to the specialist service when the guardrail check at the Checkpoint checkpoint does not allow it. Nothing was sent.

SpecialistGuardrails

The guardrail checkpoint, subjects and settings of a SpecialistRuntime. The runtime checks the Checkpoint checkpoint before every request it sends to a specialist service, when guardrail sets are named for it in GuardrailSets or an intent's GuardrailSets.

SpecialistInfo

Facts a specialist service gives about a specialist it offers.

SpecialistIntentFile

Helpers for a service adapter that exchanges intent files with its specialist service: the request's definition written as intent-file text, and an offer read from the intent-file text the service returns. Both go through the Catalog's IntentFile, so the text is the same as an intent file on disk and is checked the same way.

var text = SpecialistIntentFile.WriteRequest(request);                 // send this to the service
var offer = SpecialistIntentFile.ReadOffer(answer, "offer.intent.json"); // what the service sent back
SpecialistIntentOptions

Overrides of SpecialistOptions for one intent, set in Intents. Every property left null uses the client-wide value.

SpecialistNotEnsuredException

Thrown by a run under Explicit when no specialist is in use for the intent's current definition. Call EnsureAsync(string, CancellationToken) first.

SpecialistNotFitException

Thrown when an offered specialist did not fit and nothing requested another. The verdict was reported to the service.

SpecialistOffer

What a specialist service hands back: the intent definition to run and how to reach the specialist that runs it. Set exactly one of Provider (a provider the service adapter built) and ProviderName (a provider already configured on the client); a SpecialistRuntime refuses an offer that sets both or neither.

SpecialistOfferException

Thrown when a specialist service returns an offer the runtime cannot use, with a message that says what to change.

SpecialistOptions

The settings of a SpecialistRuntime, client-wide, with overrides for single intents in Intents. Every value can be changed; the defaults are listed on each property.

SpecialistRequest

What a SpecialistRuntime asks a specialist service for: a specialist for one intent definition, with context about how the intent is used and the requirements the specialist must meet. The request hash identifies the request's content, so the same definition and context always give the same hash.

SpecialistRequestClaim

What BeginRequestAsync(string, string, int, DateTimeOffset, CancellationToken) decided: this caller sends the request (IsBegun), a ticket is already recorded (Ticket), the hourly limit was reached (IsLimitReached), or another caller is sending it now (IsInProgress). Exactly one of the four holds.

SpecialistRequestLimitException

Thrown instead of sending a request when the intent already had as many requests in the last hour as allowed.

SpecialistRouter

A provider that passes each call to the specialist provider a SpecialistRuntime received in an offer (an offer with Provider set). Add it to the client with AddProvider(IAIProvider) (under dependency injection, services.AddNamedProvider, or AddRouter), so the client reaches it by name only and it never becomes the primary provider or part of a chain, and pass the same instance to the runtime. The runtime points each running definition at it and tags the definition with a route, which arrives in Tags; a call without a known route fails without reaching any model.

SpecialistRuntime

Runs catalog intents on specialists: models defined per intent, which an ISpecialistService provides, so an application can use several models easily, in one context or across several. The runtime obtains and uses the model for an intent; it never changes a model. It sits beside the Catalog's IntentRuntime. For each intent it sends a request built from the intent's current definition, waits until the service offers a specialist, judges whether the offer fits, and from then on runs the intent with the definition the service returned, on that specialist, through the normal pipeline. When the requested definition changes, the next ensure or run requests again and waits again, unless a KeepPreviousPolicy lets the specialist in use keep serving while the new one is handled in the background.

SpecialistServiceCollectionExtensions

Registers a SpecialistRuntime with a service collection, beside AddIntentSharp and the Catalog's AddIntentCatalog:

services.AddIntentSharp(configuration);
services.AddIntentCatalog("intents");
services.AddSingleton<ISpecialistService, MySpecialistService>();
services.AddIntentSharpSpecialist(o => o.AddRouter = true);
SpecialistServiceOptions

What AddIntentSharpSpecialist(IServiceCollection, Action<SpecialistServiceOptions>?) registers, set in its configure callback. Every part left null is taken from the container.

SpecialistStatus

A snapshot of where an intent stands with its specialist, from GetStatus(string) or EnsureAsync(string, CancellationToken).

SpecialistTicket

A specialist service's receipt for a request: the handle used to wait for the specialist, report on its fit and retire it. A SpecialistRuntime keeps it in its ISpecialistStore.

SpecialistWaitTimeoutException

Thrown when every wait for a specialist ended without an offer. No model was called for the run.

TargetContextSource

Sends what a target looks like with every request, as one item of kind Data named after the target: its command language and its entities, with each entity's kind, operations and fields. The target's DescribeAsync(TargetContext, CancellationToken) is called directly, which runs no model and passes no checkpoint; the properties of the description, its entities and its fields are not sent.

Interfaces

IFitEvaluator

Judges whether an offered specialist meets the requirement. A SpecialistRuntime runs every evaluator of FitEvaluators on each offer, in order, and the offer fits only when every finding fits. Implement it for a check of your own.

IFitJudgeMaterialBuilder

Builds what the AI fit judge reads: the material it compares. The default material holds the requested and the returned definitions as JSON, and the request's requirements. Supply your own in MaterialBuilder to show the judge something else, such as sample results.

INotFitHandler

Decides what happens after an offer does not fit: end, or request again with another definition. The runtime has already reported the verdict to the service when it is called. Nothing waits for or notifies a person.

ISpecialistContextSource

Supplies context items for an intent definition when a SpecialistRuntime builds a request. Add one to ContextSources to send, for example, the calling code or sample data with every request.

ISpecialistService

A specialist service: a provider of models for single intents, which hands back a model for an intent on request. Implement it as an adapter over the service you use; the library assumes no wire format. A SpecialistRuntime calls RequestAsync(SpecialistRequest, CancellationToken) once per request, then WaitAsync(SpecialistTicket, TimeSpan, CancellationToken) until an offer arrives or its waits run out, then ReportFitAsync(SpecialistTicket, FitReport, CancellationToken) with the verdict on the offer, and RetireAsync(SpecialistTicket, CancellationToken) when the application no longer needs the specialist.

ISpecialistStore

Where a SpecialistRuntime keeps what it knows about its requests: the ticket of each request by intent and request hash, the offer and the fit report for it, the times of the requests for the hourly limit, and the held record of the specialist in use for each intent (HeldSpecialist). InMemorySpecialistStore is the default; implement it over a database to keep requests across restarts, so a restarted application waits on its open requests instead of sending new ones. Implementations must be thread-safe.

Enums

SpecialistContextKind

What a SpecialistContextItem describes, so a specialist service can tell code from data.

SpecialistState

Where an intent stands with its specialist in a SpecialistRuntime.

SpecialistWaitMode

When a SpecialistRuntime requests a specialist and waits for it.