GenAI.Graph.NodeBehaviour behaviour (GenAI Core v0.3.0)

Copy Markdown

Behaviour Graph Node Elements must adhere to.

Summary

Functions

Define the struct of a node with default fields included.

Define the type of a node with default fields included.

Callbacks

description(graph_node)

@callback description(graph_node :: term()) :: {:ok, String.t()} | {:error, any()}

description(graph_node, default)

@callback description(graph_node :: term(), default :: any()) ::
  {:ok, String.t()} | {:error, any()}

handle(graph_node)

@callback handle(graph_node :: term()) ::
  {:ok, GenAI.Types.Graph.node_handle()} | {:error, any()}

handle(graph_node, default)

@callback handle(graph_node :: term(), default :: any()) ::
  {:ok, GenAI.Types.Graph.node_handle()} | {:error, any()}

id(graph_node)

@callback id(graph_node :: term()) :: {:ok, GenAI.Types.Graph.node_id()} | {:error, any()}

name(graph_node)

@callback name(graph_node :: term()) :: {:ok, String.t()} | {:error, any()}

name(graph_node, default)

@callback name(graph_node :: term(), default :: any()) ::
  {:ok, String.t()} | {:error, any()}

new()

@callback new() :: struct()

new(options)

@callback new(options :: term()) :: struct()

Functions

defnodestruct(values)

(macro)

Define the struct of a node with default fields included.

Example

  defnodestruct [
      value: nil,
  ]

defnodetype(types)

(macro)

Define the type of a node with default fields included.

Example

defnodetype [
   internal: boolean,
]