GenAI.Dialogue.Schema (GenAI Core v0.3.3)

Copy Markdown

Product-agnostic field schema for multi-turn slot-filling dialogues.

Fields are declared once; the dialogue stepper asks for missing required (and optional-to-ask) slots until the draft is complete.

Summary

Functions

True when no required/ask_optional fields are blank.

Ordered list of field names still blank under required + ask_optional policy.

Build a schema from a list of field maps.

Next {field, question} or nil when complete.

Types

field()

@type field() :: %{
  :name => atom(),
  :question => String.t(),
  optional(:required) => boolean()
}

t()

@type t() :: %GenAI.Dialogue.Schema{ask_optional: [atom()], fields: [field()]}

Functions

complete?(schema, draft)

@spec complete?(t(), map()) :: boolean()

True when no required/ask_optional fields are blank.

missing(schema, draft)

@spec missing(t(), map()) :: [atom()]

Ordered list of field names still blank under required + ask_optional policy.

new(fields, opts \\ [])

@spec new(
  [field()],
  keyword()
) :: t()

Build a schema from a list of field maps.

Each field: %{name: :title, question: "…", required: true | false}.

next_question(schema, draft)

@spec next_question(t(), map()) :: {atom(), String.t()} | nil

Next {field, question} or nil when complete.