StringSchema

org.llm4s.toolapi.StringSchema
See theStringSchema companion object
@Stable
final case class StringSchema extends SchemaDefinition[String]

String schema with validation options.

Value parameters

description

Human-readable description shown to the LLM

enumValues

Restricts valid values to this closed set

maxLength

Maximum allowed string length

minLength

Minimum allowed string length

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaDefinition[String]
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 withDescription(description: String): StringSchema

Replace the description shown to the LLM.

Replace the description shown to the LLM.

Attributes

def withEnum(values: Seq[String]): StringSchema

Restrict valid values to the given closed enumeration.

Restrict valid values to the given closed enumeration.

Value parameters

values

Allowed string values

Attributes

def withEnum(values: Option[Seq[String]]): StringSchema

Set or clear the closed enumeration; None lifts the restriction. Duplicates are dropped.

Set or clear the closed enumeration; None lifts the restriction. Duplicates are dropped.

Attributes

def withLengthConstraints(min: Option[Int], max: Option[Int]): StringSchema

Add minimum and/or maximum length constraints.

Add minimum and/or maximum length constraints.

Value parameters

max

Optional maximum length (inclusive)

min

Optional minimum length (inclusive)

Attributes

def withMaxLength(max: Int): StringSchema

Set the maximum allowed string length (inclusive).

Set the maximum allowed string length (inclusive).

Attributes

def withMaxLength(max: Option[Int]): StringSchema

Set or clear the maximum allowed string length (inclusive).

Set or clear the maximum allowed string length (inclusive).

Attributes

def withMinLength(min: Int): StringSchema

Set the minimum allowed string length (inclusive).

Set the minimum allowed string length (inclusive).

Attributes

def withMinLength(min: Option[Int]): StringSchema

Set or clear the minimum allowed string length (inclusive).

Set or clear the minimum allowed string length (inclusive).

Attributes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product