StopWhen
Namespace: Vercel.AI
public static class StopWhenStop-condition factories. Maps to isStepCount, hasToolCall, and isLoopFinished.
Inheritance: object
Methods
Section titled “Methods”HasToolCall(params string[])
Section titled “HasToolCall(params string[])”public static StopCondition HasToolCall(params string[] toolNames)Stops when any of <code class=“paramref”>toolNames</code> was called on the latest step.
Parameters
| Name | Type | Description |
|---|---|---|
toolNames |
string[] |
Returns: StopCondition
IsLoopFinished()
Section titled “IsLoopFinished()”public static StopCondition IsLoopFinished()A stop condition that never stops the loop. The loop still ends when a step does not call a tool.
Returns: StopCondition
IsStepCount(int)
Section titled “IsStepCount(int)”public static StopCondition IsStepCount(int count)Stops when the number of completed steps equals <code class=“paramref”>count</code>.
Parameters
| Name | Type | Description |
|---|---|---|
count |
int |
Returns: StopCondition
IsStopConditionMet(IReadOnlyList<Func<IReadOnlyList<StepResult>, Task<bool>>>, IReadOnlyList<StepResult>)
Section titled “IsStopConditionMet(IReadOnlyList<Func<IReadOnlyList<StepResult>, Task<bool>>>, IReadOnlyList<StepResult>)”public static Task<bool> IsStopConditionMet(IReadOnlyList<Func<IReadOnlyList<StepResult>, Task<bool>>> stopConditions, IReadOnlyList<StepResult> steps)Returns true when any stop condition returns true. Maps to isStopConditionMet.
Parameters
| Name | Type | Description |
|---|---|---|
stopConditions |
IReadOnlyList<Func<IReadOnlyList<StepResult>, Task<bool>>> | |
steps |
IReadOnlyList<StepResult> |
Returns: Task<bool>
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product