Schema

org.llm4s.toolapi.Schema
object Schema

Schema builder — fluent API for creating JSON Schema SchemaDefinition values.

Attributes

Example
import org.llm4s.toolapi.Schema
val schema = Schema.`object`[Map[String, Any]]("Query parameters")
 .withProperty(Schema.property("q",    Schema.string("Search query")))
 .withProperty(Schema.property("limit", Schema.integer("Max results"), required = false))
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Schema.type

Members list

Value members

Concrete methods

def `object`[T](description: String): ObjectSchema[T]

Create a JSON object schema with no initial properties. Use ObjectSchema.withProperty to add fields.

Create a JSON object schema with no initial properties. Use ObjectSchema.withProperty to add fields.

Value parameters

description

Human-readable description shown to the LLM

Attributes

def array[A](description: String, itemSchema: SchemaDefinition[A]): ArraySchema[A]

Create a JSON array schema whose items conform to itemSchema.

Create a JSON array schema whose items conform to itemSchema.

Value parameters

description

Human-readable description shown to the LLM

itemSchema

Schema applied to every element of the array

Attributes

def boolean(description: String): BooleanSchema

Create a JSON boolean schema.

Create a JSON boolean schema.

Value parameters

description

Human-readable description shown to the LLM

Attributes

def integer(description: String): IntegerSchema

Create a JSON integer schema.

Create a JSON integer schema.

Value parameters

description

Human-readable description shown to the LLM

Attributes

def nullable[T](schema: SchemaDefinition[T]): NullableSchema[T]

Wrap an existing schema to allow null as a valid value.

Wrap an existing schema to allow null as a valid value.

Value parameters

schema

The underlying non-nullable schema

Attributes

def number(description: String): NumberSchema

Create a JSON number (floating-point) schema.

Create a JSON number (floating-point) schema.

Value parameters

description

Human-readable description shown to the LLM

Attributes

def property[T](name: String, schema: SchemaDefinition[T], required: Boolean): PropertyDefinition[T]

Value parameters

name

Property key in the JSON object

required

Whether the property is required (default: true)

schema

Schema for the property value

Attributes

def string(description: String): StringSchema

Create a JSON string schema.

Create a JSON string schema.

Value parameters

description

Human-readable description shown to the LLM

Attributes