Skip to content

ToolContexts

Namespace: Vercel.AI.GenerateText

public static class ToolContexts

Validates tool context. Maps to validateToolContext.

Inheritance: object

View source

ValidateToolContext<T>(string, T, Func<T, bool>?)

Section titled “ValidateToolContext<T>(string, T, Func<T, bool>?)”
public static T ValidateToolContext<T>(string toolName, T context, Func<T, bool>? contextSchema)

Returns <code class=“paramref”>context</code> when <code class=“paramref”>contextSchema</code> is null. Otherwise returns it when the schema accepts it, and throws TypeValidationException when it does not.

Type parameters

Name Description
T

Parameters

Name Type Description
toolName string
context T
contextSchema Func<T, bool>

Returns: T

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product