Jido.AI.Signal.LLMResponse (Jido AI v2.2.0)

Copy Markdown View Source

Signal for LLM streaming/call completion.

Emitted when an LLM call completes, containing either tool calls to execute or a final answer.

Summary

Functions

Extracts tool calls from an LLMResponse signal.

Creates an LLMResponse signal from a ReqLLM response struct.

Creates a new Signal instance with the configured type and validated data.

Creates a new Signal instance, raising an error if invalid.

Checks if an LLMResponse signal contains tool calls.

Validates the data for the Signal according to its schema.

Functions

datacontenttype()

dataschema()

default_source()

extension_policy()

extract_tool_calls(arg1)

@spec extract_tool_calls(Jido.Signal.t()) :: [map()]

Extracts tool calls from an LLMResponse signal.

from_reqllm_response(response, opts)

@spec from_reqllm_response(
  map(),
  keyword()
) :: {:ok, Jido.Signal.t()} | {:error, term()}

Creates an LLMResponse signal from a ReqLLM response struct.

new(data \\ %{}, opts \\ [])

@spec new(
  map(),
  keyword()
) :: {:ok, Jido.Signal.t()} | {:error, String.t()}

Creates a new Signal instance with the configured type and validated data.

Parameters

  • data: A map containing the Signal's data payload.
  • opts: Additional Signal options (source, subject, etc.)

Returns

{:ok, Signal.t()} if the data is valid, {:error, String.t()} otherwise.

Example

MySignal.new(valid_data, source: "/custom")
# => {:ok, signal} where signal.type == MySignal.type()

new!(data \\ %{}, opts \\ [])

@spec new!(
  map(),
  keyword()
) :: Jido.Signal.t() | no_return()

Creates a new Signal instance, raising an error if invalid.

Parameters

  • data: A map containing the Signal's data payload.
  • opts: Additional Signal options (source, subject, etc.)

Returns

Signal.t() if the data is valid.

Raises

RuntimeError if the data is invalid.

Example

MySignal.new!(valid_data, source: "/custom")
# => %Jido.Signal{} with type MySignal.type()

schema()

to_json()

tool_call?(arg1)

@spec tool_call?(Jido.Signal.t()) :: boolean()

Checks if an LLMResponse signal contains tool calls.

type()

validate_data(data)

@spec validate_data(map()) :: {:ok, map()} | {:error, String.t()}

Validates the data for the Signal according to its schema.

Example

MySignal.validate_data(candidate_data)
# => {:ok, validated_data} | {:error, reason}