JsonResponseTools
Namespace: Vercel.AI.ProviderUtils
public static class JsonResponseToolsHelpers for providers that cannot combine tools with native structured output. They add an internal function tool whose arguments are the structured output, then turn that tool call back into text.
Inheritance: object
Methods
Section titled “Methods”ConvertJsonResponseToolStream(IAsyncEnumerable<LanguageModelStreamPart>, string, CancellationToken)
Section titled “ConvertJsonResponseToolStream(IAsyncEnumerable<LanguageModelStreamPart>, string, CancellationToken)”public static IAsyncEnumerable<LanguageModelStreamPart> ConvertJsonResponseToolStream(IAsyncEnumerable<LanguageModelStreamPart> source, string toolName, CancellationToken cancellationToken = default)Rewrites a language-model stream so the JSON response tool <code class=“paramref”>toolName</code> produces text.
Maps to convertJsonResponseToolStream.
Parameters
| Name | Type | Description |
|---|---|---|
source |
IAsyncEnumerable<LanguageModelStreamPart> | |
toolName |
string | |
cancellationToken |
CancellationToken |
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product