Documentation
Table of Contents

Class ScriptedProvider

Namespace
IntentSharp.Testing
Assembly
IntentSharp.dll

An in-process provider for tests. Returns canned replies in order, or computes a reply from the request. Records every request it receives so tests can check what was sent.

public sealed class ScriptedProvider : IAIProvider
Inheritance
object
ScriptedProvider
Implements
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Extension Methods

Constructors

ScriptedProvider(Func<AIRequest, string>, Func<string, float[]>?)

Creates a provider that computes every reply from the request. Queued replies are ignored.

ScriptedProvider(params string[])

Creates a provider that returns replies in order, one per call. It has no Embeddings.

Properties

CallCount

The number of completion requests received.

DefaultModel

The model name reported in every response to a request that names no model. Default "scripted-1".

Embeddings

The embedding provider that returns the embedder's vectors, with this provider's name, for a semantic memory or UseEmbeddingProvider(IEmbeddingProvider); null when the provider was created without an embedder.

Name

The provider name reported in results, also the name of Embeddings. Default "Scripted".

RequestHost

The host this provider reports as RequestHost, which the Request checkpoint carries as request.host, so a test can pin one and check a rule on hosts. Write it as the checkpoint compares it: lower case and ASCII, with no port, such as api.example.com. Null, the default, reports no host, so an enforced rule on request.host refuses the call. Nothing is sent anywhere: the provider answers in process.

Requests

Every request received, in order.

Methods

CompleteAsync(AIRequest, CancellationToken)

Records the request and returns the responder's reply, or the next queued reply, reporting the request's model, or DefaultModel when it names none. Token usage is estimated at one token per four characters.

Enqueue(string)

Adds a reply to the queue.