ToolCallConcurrencyScheduler
Namespace: Vercel.AI.GenerateText
public static class ToolCallConcurrencySchedulerTool call concurrency helpers. Maps to tool-call-concurrency.ts.
Inheritance: object
Methods
Section titled “Methods”MapWithConcurrency<TInput, TOutput>(IReadOnlyList<TInput>, int?, Func<TInput, int, Task<TOutput>>, CancellationToken)
Section titled “MapWithConcurrency<TInput, TOutput>(IReadOnlyList<TInput>, int?, Func<TInput, int, Task<TOutput>>, CancellationToken)”public static Task<IReadOnlyList<TOutput>> MapWithConcurrency<TInput, TOutput>(IReadOnlyList<TInput> items, int? concurrency, Func<TInput, int, Task<TOutput>> execute, CancellationToken cancellationToken = default)Maps items with an optional concurrency limit while preserving result order.
Workers claim items in input order. When <code class=“paramref”>cancellationToken</code> is canceled or an execution throws,
no more queued items start. Maps to mapWithConcurrency.
Type parameters
| Name | Description |
|---|---|
TInput |
|
TOutput |
Parameters
| Name | Type | Description |
|---|---|---|
items |
IReadOnlyList<TInput> | |
concurrency |
int? | |
execute |
Func<TInput, int, Task<TOutput>> | |
cancellationToken |
CancellationToken |
Returns: Task<IReadOnlyList<TOutput>>
PrepareToolCallConcurrency(int?)
Section titled “PrepareToolCallConcurrency(int?)”public static int? PrepareToolCallConcurrency(int? toolCallConcurrency)Validates the maximum number of tool calls that may execute concurrently.
Null passes through. Maps to prepareToolCallConcurrency.
Parameters
| Name | Type | Description |
|---|---|---|
toolCallConcurrency |
int? |
Returns: int?
Exceptions
| Type | Condition |
|---|---|
| InvalidArgumentError | Thrown when <code class=“paramref”>toolCallConcurrency</code> is below 1. |
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product