BatchResultsApiBase
Namespace: Vercel.AI.ProviderUtils
public abstract class BatchResultsApiBase : IBatchApiBatch API that downloads results. Start, status, cancel, and list throw unless a provider overrides them.
Inheritance: object
Implements: IBatchApi
Derived: AnthropicBatchApi, GatewayBatchApi, GoogleBatchApi, OpenAIBatchApi
Properties
Section titled “Properties”CanCancel
Section titled “CanCancel”public virtual bool CanCancel { get; }True when cancellation is implemented.
Value: bool
CanList
Section titled “CanList”public virtual bool CanList { get; }True when listing is implemented.
Value: bool
Provider
Section titled “Provider”public abstract string Provider { get; }Provider id.
Value: string
Methods
Section titled “Methods”ConvertRows(IAsyncEnumerable<JsonElement>, Func<JsonElement, BatchItem>, CancellationToken)
Section titled “ConvertRows(IAsyncEnumerable<JsonElement>, Func<JsonElement, BatchItem>, CancellationToken)”protected static IAsyncEnumerable<BatchItem> ConvertRows(IAsyncEnumerable<JsonElement> rows, Func<JsonElement, BatchItem> convert, CancellationToken cancellationToken = default)Converts each row of a JSON Lines download as it is read.
Parameters
| Name | Type | Description |
|---|---|---|
rows |
IAsyncEnumerable<JsonElement> | |
convert |
Func<JsonElement, BatchItem> | |
cancellationToken |
CancellationToken |
Returns: IAsyncEnumerable<BatchItem>
DoCancelAsync(BatchOperationCall, CancellationToken)
Section titled “DoCancelAsync(BatchOperationCall, CancellationToken)”public virtual Task<BatchCancelResult> DoCancelAsync(BatchOperationCall call, CancellationToken cancellationToken)Cancels a batch.
Parameters
| Name | Type | Description |
|---|---|---|
call |
BatchOperationCall | |
cancellationToken |
CancellationToken |
Returns: Task<BatchCancelResult>
DoGetResultsAsync(BatchOperationCall, CancellationToken)
Section titled “DoGetResultsAsync(BatchOperationCall, CancellationToken)”public abstract Task<IAsyncEnumerable<BatchItem>> DoGetResultsAsync(BatchOperationCall call, CancellationToken cancellationToken)Opens the result stream. Errors found while opening, such as a batch that is not complete, throw from the task. Errors found while reading, such as a malformed row, throw from the stream.
Parameters
| Name | Type | Description |
|---|---|---|
call |
BatchOperationCall | |
cancellationToken |
CancellationToken |
Returns: Task<IAsyncEnumerable<BatchItem>>
DoGetStatusAsync(BatchOperationCall, CancellationToken)
Section titled “DoGetStatusAsync(BatchOperationCall, CancellationToken)”public virtual Task<BatchStatus> DoGetStatusAsync(BatchOperationCall call, CancellationToken cancellationToken)Reads status.
Parameters
| Name | Type | Description |
|---|---|---|
call |
BatchOperationCall | |
cancellationToken |
CancellationToken |
Returns: Task<BatchStatus>
DoListAsync(BatchOperationCall, CancellationToken)
Section titled “DoListAsync(BatchOperationCall, CancellationToken)”public virtual Task<BatchListResult> DoListAsync(BatchOperationCall call, CancellationToken cancellationToken)Lists batches. The implementation is invoked on this instance.
Parameters
| Name | Type | Description |
|---|---|---|
call |
BatchOperationCall | |
cancellationToken |
CancellationToken |
Returns: Task<BatchListResult>
DoStartAsync(BatchOperationCall, CancellationToken)
Section titled “DoStartAsync(BatchOperationCall, CancellationToken)”public virtual Task<BatchStartResult> DoStartAsync(BatchOperationCall call, CancellationToken cancellationToken)Starts a batch.
Parameters
| Name | Type | Description |
|---|---|---|
call |
BatchOperationCall | |
cancellationToken |
CancellationToken |
Returns: Task<BatchStartResult>
Str(JsonElement, string)
Section titled “Str(JsonElement, string)”protected static string? Str(JsonElement element, string name)Text of a string property, or null.
Parameters
| Name | Type | Description |
|---|---|---|
element |
JsonElement | |
name |
string |
Returns: string
TextItem(string, IEnumerable<string>, string?, string?, string?)
Section titled “TextItem(string, IEnumerable<string>, string?, string?, string?)”protected static BatchItem TextItem(string id, IEnumerable<string> texts, string? finishReason, string? responseId, string? modelId)Builds a succeeded text item from joined text parts.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string | |
texts |
IEnumerable<string> | |
finishReason |
string | |
responseId |
string | |
modelId |
string |
Returns: BatchItem
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product