Package com.tnsai.tools
Record Class ToolExample
java.lang.Object
java.lang.Record
com.tnsai.tools.ToolExample
- Record Components:
input- the example input/querydescription- human-readable description of what this example demonstratesexpectedOutput- optional expected output (for documentation)category- optional category to group examples
public record ToolExample(String input, String description, String expectedOutput, String category)
extends Record
Represents a usage example for a tool.
Tool examples help LLMs understand how to use tools effectively by providing concrete input/output pairs with descriptions.
Usage
// Simple example
ToolExample example = ToolExample.of(
"quantum physics",
"Search for quantum physics articles"
);
// Example with expected output
ToolExample example = ToolExample.withOutput(
"2 + 2",
"Simple addition",
"4"
);
// Detailed example
ToolExample example = ToolExample.builder()
.input("weather in Tokyo")
.description("Get current weather for Tokyo")
.expectedOutput("Temperature: 15°C, Sunny")
.category("weather")
.build();
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionToolExample(String input, String description, String expectedOutput, String category) Creates a tool example with validation. -
Method Summary
Modifier and TypeMethodDescriptionstatic ToolExample.Builderbuilder()Creates a tool example builder.static ToolExamplecategorized(String input, String description, String category) Creates a categorized tool example.category()Returns the value of thecategoryrecord component.Returns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpectedOutputrecord component.format()Formats this example for LLM consumption.Formats this example in a compact single-line format.final inthashCode()Returns a hash code value for this object.input()Returns the value of theinputrecord component.static ToolExampleCreates a simple tool example.final StringtoString()Returns a string representation of this record class.static ToolExamplewithOutput(String input, String description, String expectedOutput) Creates a tool example with expected output.
-
Constructor Details
-
ToolExample
Creates a tool example with validation.
-
-
Method Details
-
of
Creates a simple tool example.- Parameters:
input- the example inputdescription- what this example demonstrates- Returns:
- new tool example
-
withOutput
Creates a tool example with expected output.- Parameters:
input- the example inputdescription- what this example demonstratesexpectedOutput- the expected output- Returns:
- new tool example
-
categorized
Creates a categorized tool example.- Parameters:
input- the example inputdescription- what this example demonstratescategory- the example category- Returns:
- new tool example
-
builder
Creates a tool example builder.- Returns:
- new builder
-
format
Formats this example for LLM consumption.- Returns:
- formatted example string
-
formatCompact
Formats this example in a compact single-line format.- Returns:
- compact format
-
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). -
input
Returns the value of theinputrecord component.- Returns:
- the value of the
inputrecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
expectedOutput
Returns the value of theexpectedOutputrecord component.- Returns:
- the value of the
expectedOutputrecord component
-
category
Returns the value of thecategoryrecord component.- Returns:
- the value of the
categoryrecord component
-