# `Dsxir.Signature`

Declarative signature module. Wraps `Spark.Dsl` so authors write:

    defmodule MyApp.AnswerQuestion do
      use Dsxir.Signature

      signature do
        instruction "Answer the user's question."
        input :question, :string
        output :answer, :string, desc: "A direct factual answer."
      end
    end

Inline string-form signatures are also supported via `from_string/2` and may
be passed directly to the Module DSL `predictor` entity:

    predictor :answer, Dsxir.Predictor.Predict, signature: "question -> answer"

The grammar mirrors DSPy's: `inputs -> outputs` with optional `name: type`
annotations.

### Options

* `:extensions` (list of module that adopts `Spark.Dsl.Extension`) - A list of DSL extensions to add to the `Spark.Dsl`

* `:otp_app` (`t:atom/0`) - The otp_app to use for any application configurable options

* `:fragments` (list of `t:module/0`) - Fragments to include in the `Spark.Dsl`. See the fragments guide for more.

# `from_string`

```elixir
@spec from_string(
  String.t(),
  keyword()
) :: {:ok, Dsxir.Signature.Compiled.t()} | {:error, term()}
```

Compile a string-form signature into a `Dsxir.Signature.Compiled{}`.

Returns `{:ok, compiled}` on success or `{:error, reason}` on parse failure.
Use `from_string!/2` for the raising variant.

# `from_string!`

```elixir
@spec from_string!(
  String.t(),
  keyword()
) :: Dsxir.Signature.Compiled.t()
```

Compile a string-form signature, raising `Dsxir.Errors.Invalid.Signature` on
parse failure.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
