ObjectSchema

org.llm4s.toolapi.ObjectSchema
See theObjectSchema companion object
@Stable
final case class ObjectSchema[T] extends SchemaDefinition[T]

Object schema with a fixed set of typed properties.

In strict mode all properties are emitted as required regardless of the individual PropertyDefinition.required flag, matching the behaviour expected by OpenAI strict-mode tool definitions.

Value parameters

additionalProperties

Whether to allow extra keys beyond those listed

description

Human-readable description shown to the LLM

properties

Ordered sequence of property definitions

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaDefinition[T]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def toJsonSchema(strict: Boolean): Value

Serialise this schema to a JSON Schema ujson.Value.

Serialise this schema to a JSON Schema ujson.Value.

Value parameters

strict

When true, all object properties are treated as required, matching OpenAI strict-mode tool definitions.

Attributes

def withAdditionalProperties(allowed: Boolean): ObjectSchema[T]

Set whether keys beyond the listed properties are allowed.

Set whether keys beyond the listed properties are allowed.

Attributes

def withDescription(description: String): ObjectSchema[T]

Replace the description shown to the LLM.

Replace the description shown to the LLM.

Attributes

def withOptionalField[P](name: String, schema: SchemaDefinition[P]): ObjectSchema[T]

Add an optional field to the object schema

Add an optional field to the object schema

Value parameters

name

The name of the property

schema

The schema definition for the property

Attributes

Returns

A new ObjectSchema with the optional property added

def withProperties(properties: Seq[PropertyDefinition[_]]): ObjectSchema[T]

Replace the whole property list; withProperty appends one.

Replace the whole property list; withProperty appends one.

Attributes

def withProperty[P](property: PropertyDefinition[P]): ObjectSchema[T]

Return a copy of this schema with property appended to the properties list.

Return a copy of this schema with property appended to the properties list.

Value parameters

property

The property definition to add

Attributes

def withRequiredField[P](name: String, schema: SchemaDefinition[P]): ObjectSchema[T]

Add a required field to the object schema

Add a required field to the object schema

Value parameters

name

The name of the property

schema

The schema definition for the property

Attributes

Returns

A new ObjectSchema with the required property added

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product