Record Class ToolCall
- Record Components:
name- the name of the tool that was calledarguments- the arguments passed to the toolresult- the tool execution result (may be null)metadata- optional metadata (latency, tokens, etc.)
Contains the tool name, arguments passed, optional result, and metadata such as latency or token usage.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructing tool calls. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theargumentsrecord component.<T> TargumentsAs(OutputType<T> type) Converts this tool call'sargumentsmap into a generic target captured by anOutputTypetoken, for examplenew OutputType<List<String>>() {}.<T> TargumentsAs(Class<T> type) Converts this tool call'sargumentsmap into an instance oftype.static ToolCall.Builderbuilder()Creates a new builder for constructing tool calls.final booleanIndicates whether some other object is "equal to" this one.static ToolCallCreates a tool call from a map, typically when deserializing from a JSON dataset.final inthashCode()Returns a hash code value for this object.metadata()Returns the value of themetadatarecord component.<T> TmetadataAs(String key, OutputType<T> type) Reads the metadata entry stored underkeyand converts it into a generic target captured by anOutputTypetoken, for examplenew OutputType<List<String>>() {}.<T> TmetadataAs(String key, Class<T> type) Reads the metadata entry stored underkeyand converts it into an instance oftype.name()Returns the value of thenamerecord component.static ToolCallCreates a tool call with just a name and arguments.result()Returns the value of theresultrecord component.<T> TresultAs(OutputType<T> type) Deserializes this tool call'sresultstring into a generic target captured by anOutputTypetoken, for examplenew OutputType<List<Order>>() {}.<T> TDeserializes this tool call'sresultstring into an instance oftype.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
of
Creates a tool call with just a name and arguments.- Parameters:
name- the tool namearguments- the arguments passed to the tool- Returns:
- a new tool call
-
fromMap
Creates a tool call from a map, typically when deserializing from a JSON dataset.Expected keys:
"name","arguments","result","metadata".- Parameters:
map- the map to create from- Returns:
- a new tool call
-
resultAs
Deserializes this tool call'sresultstring into an instance oftype.This is the read-side counterpart to
ToolCall.Builder.resultJson(Object): a structured tool result stored as compact JSON is round-tripped back into a typed object. Anullor blank result yieldsnull, and the JSON literal"null"also parses tonull.The result must be a JSON string for this to work. Both
ToolCall.Builder.resultJson(Object)andfromMap(Map)guarantee that:fromMapkeeps aStringresult verbatim and serializes any structured value (aMap, list, or other object) to compact JSON, so a structured result from a deserialized dataset round-trips here as well.- Type Parameters:
T- the target type- Parameters:
type- the target class- Returns:
- the deserialized result, or
nullif the result isnull/blank/JSON null - Throws:
DokimosTypeConversionException- if the result cannot be parsed intotype
-
resultAs
Deserializes this tool call'sresultstring into a generic target captured by anOutputTypetoken, for examplenew OutputType<List<Order>>() {}.Use this overload when the target type has type arguments that a plain
Class<T>cannot express. The same null/blank/JSON-null handling described onresultAs(Class)applies.- Type Parameters:
T- the target type- Parameters:
type- the captured generic output type- Returns:
- the deserialized result, or
nullif the result isnull/blank/JSON null - Throws:
DokimosTypeConversionException- if the result cannot be parsed intotype
-
argumentsAs
Converts this tool call'sargumentsmap into an instance oftype.The arguments are already an in-memory map, so this converts in place (no textual round-trip).
arguments()is nevernull(it defaults to an empty map); converting an empty map to a record or bean yields an instance with default/empty fields.- Type Parameters:
T- the target type- Parameters:
type- the target class- Returns:
- the converted arguments
- Throws:
DokimosTypeConversionException- if the arguments cannot be converted totype
-
argumentsAs
Converts this tool call'sargumentsmap into a generic target captured by anOutputTypetoken, for examplenew OutputType<List<String>>() {}.Use this overload when the target type has type arguments that a plain
Class<T>cannot express.- Type Parameters:
T- the target type- Parameters:
type- the captured generic output type- Returns:
- the converted arguments
- Throws:
DokimosTypeConversionException- if the arguments cannot be converted totype
-
metadataAs
Reads the metadata entry stored underkeyand converts it into an instance oftype.The value is already in memory, so this converts in place (no textual round-trip). An absent key (or a
nullstored value) yieldsnull.- Type Parameters:
T- the target type- Parameters:
key- the metadata keytype- the target class- Returns:
- the converted value, or
nullif the key is absent or its value isnull - Throws:
DokimosTypeConversionException- if the value cannot be converted totype
-
metadataAs
Reads the metadata entry stored underkeyand converts it into a generic target captured by anOutputTypetoken, for examplenew OutputType<List<String>>() {}.An absent key (or a
nullstored value) yieldsnull.- Type Parameters:
T- the target type- Parameters:
key- the metadata keytype- the captured generic output type- Returns:
- the converted value, or
nullif the key is absent or its value isnull - Throws:
DokimosTypeConversionException- if the value cannot be converted totype
-
builder
Creates a new builder for constructing tool calls.- Returns:
- a new builder
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
arguments
Returns the value of theargumentsrecord component.- Returns:
- the value of the
argumentsrecord component
-
result
Returns the value of theresultrecord component.- Returns:
- the value of the
resultrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-