Package dev.agenor.core.llm
Record Class FunctionDefinition
java.lang.Object
java.lang.Record
dev.agenor.core.llm.FunctionDefinition
- Record Components:
name- the name of the functiondescription- a description of what the function doesparameters- the JSON Schema defining the function's parameters
public record FunctionDefinition(String name, String description, Map<String,Object> parameters)
extends Record
Defines a function that can be called by an LLM.
Function calling (also known as tool use) allows LLMs to request the execution of external functions to gather information or perform actions. This class describes the function's name, purpose, and parameters using JSON Schema.
Example usage:
FunctionDefinition weatherFunction = FunctionDefinition.builder("get_weather")
.description("Get the current weather for a location")
.parameter("location", "string", "The city and state, e.g. San Francisco, CA", true)
.parameter("unit", "string", "Temperature unit (celsius or fahrenheit)", false)
.build();
- Since:
- 0.3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating FunctionDefinition instances. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FunctionDefinition.BuilderCreate a new builder.Returns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.Get the parameter schema.Get the properties definition.Get the list of required parameters.final inthashCode()Returns a hash code value for this object.booleanisParameterRequired(String parameterName) Check if a parameter is required.name()Returns the value of thenamerecord component.Returns the value of theparametersrecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
FunctionDefinition
Compact constructor with validation and defensive copying.
-
-
Method Details
-
builder
Create a new builder.- Parameters:
name- the function name- Returns:
- a new builder
-
getParameterSchema
Get the parameter schema.- Returns:
- the JSON Schema for parameters
-
getRequiredParameters
Get the list of required parameters.- Returns:
- list of required parameter names, or empty list if none
-
isParameterRequired
Check if a parameter is required.- Parameters:
parameterName- the parameter name to check- Returns:
- true if the parameter is required
-
getProperties
Get the properties definition.- Returns:
- map of parameter properties
-
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
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
parameters
Returns the value of theparametersrecord component.- Returns:
- the value of the
parametersrecord component
-