Zoonk.AI.AISchema (Zoonk v0.1.0-dev)

View Source

Defines schema specifications for structured AI outputs.

This module lets you create JSON Schema definitions to ensure AI responses follow a specific structure.

It supports nested schemas and field definitions with various data types.

Summary

Functions

Adds fields to the schema.

Functions

add_field(ai_schema, fields)

Adds fields to the schema.

Examples

iex> AISchema.add_field(%AISchema{}, %{name: "string"})
%AISchema{schema: %{properties: %{name: %{type: "string"}}}}

iex> AISchema.add_field(%AISchema{}, %{age: "integer", name: "string"})
%AISchema{schema: %{properties: %{age: %{type: "integer"}, name: %{type: "string"}}}}

iex> AISchema.add_field(%AISchema{}, %{courses: [%{title: "string"}]})
%AISchema{schema: %{properties: %{courses: %{type: "array", items: %{type: "object", properties: %{title: %{type: "string"}}}}}}}

iex> AISchema.add_field(%AISchema{}, [%{title: "string"}])
%AISchema{schema: %{type: "array", items: %{type: "object", properties: %{title: %{type: "string"}}}}}