Lux.Prism behaviour (Lux v0.5.0)
View SourceModular, composable units of functionality for defining actions.
Prisms are used to define actions that can be executed by agents.
Example
defmodule MyApp.Prisms.WeatherPrism do
use Lux.Prism,
name: "Weather Data",
description: "Fetches weather data for a given location",
input_schema: %{
type: :object,
properties: %{
location: %{type: :string, description: "City name"},
units: %{type: :string, description: "Temperature units (C/F)"}
}
}
def handler(input, _ctx) do
# Implementation
end
end
Summary
Types
A handler is a function or a module that handles the data.
An optional type of a type t
is a type that can be either the type t
or nil
.
A schema is either a map of key-value pairs that describe the structure of the data, or a module that implements the Lux.SignalSchema behaviour.
A validator is a function or a module that validates the data.
Callbacks
A handler is the function that will be called when the prism is executed.
Functions
Creates a new prism from a map or keyword list.
Resolves a schema reference to its actual schema definition. If the schema is a module that implements Lux.SignalSchema, returns its schema. Otherwise, returns the schema as is.
Types
A handler is a function or a module that handles the data.
@type nullable(t) :: t | nil
An optional type of a type t
is a type that can be either the type t
or nil
.
A schema is either a map of key-value pairs that describe the structure of the data, or a module that implements the Lux.SignalSchema behaviour.
A validator is a function or a module that validates the data.
Callbacks
Functions
Creates a new prism from a map or keyword list.
Resolves a schema reference to its actual schema definition. If the schema is a module that implements Lux.SignalSchema, returns its schema. Otherwise, returns the schema as is.