AgentPrismGeneratedToolArguments
AgentPrism.Abstractions.dllThe helper methods called by tool wrappers produced by the source generator while converting JSON arguments to CLR types.
public static class AgentPrismGeneratedToolArgumentsInheritance
Section titled “Inheritance”object ← AgentPrismGeneratedToolArguments
Inherited Members
Section titled “Inherited Members”object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”This class is designed to be called only by code generated by the
[AgentPrismTool] generator; calling it by hand is not a supported
scenario. The only reason it is public is that the generated code lives
in the consumer’s own assembly and therefore needs to reach this type from outside this compilation.
No conversion uses reflection: everything works through
JsonElement’s type-specific Get* methods or through
the converter delegate the caller supplies.
Methods
Section titled “Methods”GetArray<T>(AIFunctionArguments, string, Func<JsonElement, T>, bool, IReadOnlyList<T>?)
Section titled “ GetArray<T>(AIFunctionArguments, string, Func<JsonElement, T>, bool, IReadOnlyList<T>?)”Reads an array argument; each element is converted with the same converter.
public static IReadOnlyList<T> GetArray<T>(AIFunctionArguments arguments, string name, Func<JsonElement, T> convert, bool required, IReadOnlyList<T>? defaultValue)Parameters
Section titled “Parameters”arguments AIFunctionArguments
The call’s arguments.
name string
The argument’s JSON key.
convert Func<JsonElement, T>
The converter that converts each element.
required bool
Whether to throw if the argument is missing.
defaultValue IReadOnlyList<T>?
The value to use if required is false
and the argument is missing. An empty list is used if null.
Returns
Section titled “Returns”The converted array.
Type Parameters
Section titled “Type Parameters”T
The array element type.
Exceptions
Section titled “Exceptions”The argument is required but missing, or the given value is not a JSON array.
GetOptional<T>(AIFunctionArguments, string, Func<JsonElement, T>, T)
Section titled “ GetOptional<T>(AIFunctionArguments, string, Func<JsonElement, T>, T)”Reads an optional argument; returns the given default if missing.
public static T GetOptional<T>(AIFunctionArguments arguments, string name, Func<JsonElement, T> convert, T defaultValue)Parameters
Section titled “Parameters”arguments AIFunctionArguments
The call’s arguments.
name string
The argument’s JSON key.
convert Func<JsonElement, T>
The converter that turns a JsonElement into T.
defaultValue T
The value to use if the argument is missing.
Returns
Section titled “Returns”T
The converted value, or defaultValue.
Type Parameters
Section titled “Type Parameters”T
The target CLR type.
Exceptions
Section titled “Exceptions”The argument was given but is an unexpected CLR type.
GetRequired<T>(AIFunctionArguments, string, Func<JsonElement, T>)
Section titled “ GetRequired<T>(AIFunctionArguments, string, Func<JsonElement, T>)”Reads a required argument; throws if missing.
public static T GetRequired<T>(AIFunctionArguments arguments, string name, Func<JsonElement, T> convert)Parameters
Section titled “Parameters”arguments AIFunctionArguments
The call’s arguments.
name string
The argument’s JSON key.
convert Func<JsonElement, T>
The converter that turns a JsonElement into T.
Returns
Section titled “Returns”T
The converted value.
Type Parameters
Section titled “Type Parameters”T
The target CLR type.
Exceptions
Section titled “Exceptions”The argument is missing, or is an unexpected CLR type.