TestLanguageModel
Namespace: Vercel.AI.Testing
public sealed class TestLanguageModel : ILanguageModelLanguage model that returns scripted generate and stream results.
Inheritance: object
Implements: ILanguageModel
Constructors
Section titled “Constructors”TestLanguageModel(string)
Section titled “TestLanguageModel(string)”public TestLanguageModel(string modelId = "test")Creates a model with id <code class=“paramref”>modelId</code>.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Properties
Section titled “Properties”public List<LanguageModelCallOptions> Calls { get; }Calls observed by generate and stream.
Value: List<LanguageModelCallOptions>
ModelId
Section titled “ModelId”public string ModelId { get; }Model id.
Value: string
OnGenerate
Section titled “OnGenerate”public Func<LanguageModelCallOptions, LanguageModelGenerateResult>? OnGenerate { get; set; }When set, generate returns this function’s result.
Value: Func<LanguageModelCallOptions, LanguageModelGenerateResult>
Provider
Section titled “Provider”public string Provider { get; }Provider id, such as openai.
Value: string
SpecificationVersion
Section titled “SpecificationVersion”public string SpecificationVersion { get; }Always V4.
Value: string
StreamParts
Section titled “StreamParts”public IReadOnlyList<LanguageModelStreamPart>? StreamParts { get; set; }When set, stream yields these parts instead of a single text delta.
Value: IReadOnlyList<LanguageModelStreamPart>
StreamRequest
Section titled “StreamRequest”public LanguageModelStreamRequest? StreamRequest { get; set; }The request info stream calls report.
Value: LanguageModelStreamRequest
StreamResponse
Section titled “StreamResponse”public LanguageModelStreamResponse? StreamResponse { get; set; }The response info stream calls report.
Value: LanguageModelStreamResponse
Methods
Section titled “Methods”DoGenerateAsync(LanguageModelCallOptions, CancellationToken)
Section titled “DoGenerateAsync(LanguageModelCallOptions, CancellationToken)”public Task<LanguageModelGenerateResult> DoGenerateAsync(LanguageModelCallOptions options, CancellationToken cancellationToken)Generates a complete result.
Parameters
| Name | Type | Description |
|---|---|---|
options |
LanguageModelCallOptions | |
cancellationToken |
CancellationToken |
Returns: Task<LanguageModelGenerateResult>
DoStreamAsync(LanguageModelCallOptions, CancellationToken)
Section titled “DoStreamAsync(LanguageModelCallOptions, CancellationToken)”public Task<LanguageModelStreamResult> DoStreamAsync(LanguageModelCallOptions options, CancellationToken cancellationToken)Streams partial results. The result carries the stream with the request and response info.
Parameters
| Name | Type | Description |
|---|---|---|
options |
LanguageModelCallOptions | |
cancellationToken |
CancellationToken |
Returns: Task<LanguageModelStreamResult>
Text(string)
Section titled “Text(string)”public static LanguageModelGenerateResult Text(string text)A generate result whose only content is <code class=“paramref”>text</code>.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
Returns: LanguageModelGenerateResult
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product