Documentation
¶
Overview ¶
Package schema provides helpers for working with JSON Schema definitions in the AI SDK ecosystem.
This is the Go equivalent of the AI SDK's jsonSchema function.
The package provides type-safe JSON Schema construction utilities that integrate with the tool and structured-output systems.
Index ¶
- type JSONSchema
- func (s *JSONSchema) BoolProp(name, description string) *JSONSchema
- func (s *JSONSchema) Build() json.RawMessage
- func (s *JSONSchema) Description(desc string) *JSONSchema
- func (s *JSONSchema) Items(item *JSONSchema) *JSONSchema
- func (s *JSONSchema) NumberProp(name, description string) *JSONSchema
- func (s *JSONSchema) Required(names ...string) *JSONSchema
- func (s *JSONSchema) StringProp(name, description string) *JSONSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONSchema ¶
type JSONSchema struct {
// contains filtered or unexported fields
}
JSONSchema is a builder for constructing JSON Schema objects that are compatible with AI model tool definitions and structured outputs.
func NewJSONSchema ¶
func NewJSONSchema(schemaType string) *JSONSchema
NewJSONSchema creates a new JSONSchema builder initialised with the given type.
func (*JSONSchema) BoolProp ¶
func (s *JSONSchema) BoolProp(name, description string) *JSONSchema
BoolProp adds a boolean property to an object schema.
func (*JSONSchema) Build ¶
func (s *JSONSchema) Build() json.RawMessage
Build returns the schema as a json.RawMessage suitable for use in tool definitions and structured output specifications.
func (*JSONSchema) Description ¶
func (s *JSONSchema) Description(desc string) *JSONSchema
Description sets the schema description.
func (*JSONSchema) Items ¶
func (s *JSONSchema) Items(item *JSONSchema) *JSONSchema
Items sets the items schema for an array type.
func (*JSONSchema) NumberProp ¶
func (s *JSONSchema) NumberProp(name, description string) *JSONSchema
NumberProp adds a number property to an object schema.
func (*JSONSchema) Required ¶
func (s *JSONSchema) Required(names ...string) *JSONSchema
Required marks the named properties as required.
func (*JSONSchema) StringProp ¶
func (s *JSONSchema) StringProp(name, description string) *JSONSchema
StringProp adds a string property to an object schema.