A Jido.Action for generating text embeddings using LLM embedding models.
This action uses ReqLLM's embedding functionality to generate vector embeddings for text. Embeddings can be used for semantic search, similarity comparison, and other NLP tasks.
Parameters
model(optional) - Model alias (e.g.,:embedding) or direct model spec (default::embedding)texts(optional) - Single text string to embedtexts_list(optional) - List of texts to embeddimensions(optional) - Output dimensions for models that support ittimeout(optional) - Request timeout in milliseconds
Provide either texts or texts_list.
Examples
# Single text embedding
{:ok, result} = Jido.Exec.run(Jido.AI.Actions.LLM.Embed, %{
texts: "Hello world"
})
# Batch embeddings
{:ok, result} = Jido.Exec.run(Jido.AI.Actions.LLM.Embed, %{
texts_list: ["Hello world", "Elixir is great"]
})
# With dimensions
{:ok, result} = Jido.Exec.run(Jido.AI.Actions.LLM.Embed, %{
model: :embedding,
texts: "Semantic search",
dimensions: 1536
})Result Format
%{
embeddings: [[0.1, 0.2, ...], [0.3, 0.4, ...]],
count: 2,
model: "openai:text-embedding-3-small",
dimensions: 1536
}
Summary
Functions
Returns the Action metadata. Alias for to_json/0.
Returns the category of the Action.
Returns the description of the Action.
Returns the name of the Action.
Lifecycle hook called after Action execution.
Lifecycle hook called after output validation.
Lifecycle hook called after parameter validation.
Lifecycle hook called before output validation.
Lifecycle hook called before parameter validation.
Lifecycle hook called when an error occurs.
Returns the output schema of the Action.
Executes the embedding action.
Returns the input schema of the Action.
Returns the tags associated with the Action.
Returns the Action metadata as a JSON-serializable map.
Converts the Action to an LLM-compatible tool format.
Validates the output result for the Action.
Validates the input parameters for the Action.
Returns the version of the Action.
Functions
Returns the Action metadata. Alias for to_json/0.
Returns the category of the Action.
Returns the description of the Action.
Returns the name of the Action.
Lifecycle hook called after Action execution.
Lifecycle hook called after output validation.
Lifecycle hook called after parameter validation.
Lifecycle hook called before output validation.
Lifecycle hook called before parameter validation.
Lifecycle hook called when an error occurs.
Returns the output schema of the Action.
Executes the embedding action.
Returns
{:ok, result}- Successful response withembeddings,count,model, anddimensionskeys{:error, reason}- Error from ReqLLM or validation
Returns the input schema of the Action.
Returns the tags associated with the Action.
Returns the Action metadata as a JSON-serializable map.
Converts the Action to an LLM-compatible tool format.
Validates the output result for the Action.
Examples
iex> defmodule ExampleAction do
...> use Jido.Action,
...> name: "example_action",
...> output_schema: [
...> result: [type: :string, required: true]
...> ]
...> end
...> ExampleAction.validate_output(%{result: "test", extra: "ignored"})
{:ok, %{result: "test", extra: "ignored"}}
iex> ExampleAction.validate_output(%{extra: "ignored"})
{:error, "Invalid output for Action: Required key :result not found"}
Validates the input parameters for the Action.
Examples
iex> defmodule ExampleAction do
...> use Jido.Action,
...> name: "example_action",
...> schema: [
...> input: [type: :string, required: true]
...> ]
...> end
...> ExampleAction.validate_params(%{input: "test"})
{:ok, %{input: "test"}}
iex> ExampleAction.validate_params(%{})
{:error, "Invalid parameters for Action: Required key :input not found"}
Returns the version of the Action.