DecisionState
Namespace: Vercel.AI.Operations
public sealed class DecisionStateShared state of a decision: text, a JSON object, or ordered parts. Maps to DecisionState.
A JSON array is not valid state. Wrap it in an object or in a DecisionJsonPart.
CancellationToken) maps to prepareDecisionState.
Inheritance: object
Properties
Section titled “Properties”public JsonElement? Json { get; }The JSON object, when the state is an object.
Value: JsonElement?
public IReadOnlyList<DecisionStatePart>? Parts { get; }The parts, when the state is a list of parts.
Value: IReadOnlyList<DecisionStatePart>
public string? Text { get; }The text, when the state is a string.
Value: string
Methods
Section titled “Methods”From(IReadOnlyList<DecisionStatePart>)
Section titled “From(IReadOnlyList<DecisionStatePart>)”public static DecisionState From(IReadOnlyList<DecisionStatePart> parts)Creates state from ordered parts.
Parameters
| Name | Type | Description |
|---|---|---|
parts |
IReadOnlyList<DecisionStatePart> |
Returns: DecisionState
From(string)
Section titled “From(string)”public static DecisionState From(string text)Creates state from text.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
Returns: DecisionState
FromJson(JsonElement)
Section titled “FromJson(JsonElement)”public static DecisionState FromJson(JsonElement value)Creates state from a JSON object. Any other JSON value throws InvalidArgumentException.
Parameters
| Name | Type | Description |
|---|---|---|
value |
JsonElement |
Returns: DecisionState
PrepareDecisionStateAsync(DecisionState, CancellationToken)
Section titled “PrepareDecisionStateAsync(DecisionState, CancellationToken)”public static Task<IReadOnlyList<DecisionModelStatePart>> PrepareDecisionStateAsync(DecisionState state, CancellationToken cancellationToken = default)Turns public state into the list of parts the model receives. URL files are downloaded. File media types are resolved to a full type.
Parameters
| Name | Type | Description |
|---|---|---|
state |
DecisionState | |
cancellationToken |
CancellationToken |
Returns: Task<IReadOnlyList<DecisionModelStatePart>>
Operators
Section titled “Operators”implicit operator DecisionState(string)
Section titled “implicit operator DecisionState(string)”public static implicit operator DecisionState(string text)Converts text to state.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
Returns: DecisionState
implicit operator DecisionState(DecisionStatePart[])
Section titled “implicit operator DecisionState(DecisionStatePart[])”public static implicit operator DecisionState(DecisionStatePart[] parts)Converts an array of parts to state.
Parameters
| Name | Type | Description |
|---|---|---|
parts |
DecisionStatePart\[\] |
Returns: DecisionState
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product