Jido.AI.Actions.OpenaiEx (Jido AI v0.5.2)
View SourceSummary
Functions
Callback implementation for Jido.Action.on_after_run/1
.
Callback implementation for Jido.Action.on_after_validate_params/1
.
Callback implementation for Jido.Action.on_before_validate_params/1
.
Callback implementation for Jido.Action.on_error/4
.
Runs a chat completion request using OpenAI Ex.
Validates the input parameters for the Action.
Functions
Callback implementation for Jido.Action.on_after_run/1
.
Callback implementation for Jido.Action.on_after_validate_params/1
.
Callback implementation for Jido.Action.on_before_validate_params/1
.
Callback implementation for Jido.Action.on_error/4
.
Runs a chat completion request using OpenAI Ex.
Parameters
- params: Map containing:
- model: Either a %Jido.AI.Model{} struct or a tuple of {provider, opts}
- messages: List of message maps with :role and :content (required if prompt is not provided)
- prompt: A %Jido.AI.Prompt{} struct or string (required if messages is not provided)
- tools: Optional list of Jido.Action modules for function calling
- tool_choice: Optional tool choice configuration
- temperature: Optional float between 0 and 2 (defaults to model's temperature)
- max_tokens: Optional integer (defaults to model's max_tokens)
- top_p: Optional float between 0 and 1
- frequency_penalty: Optional float between -2.0 and 2.0
- presence_penalty: Optional float between -2.0 and 2.0
- stop: Optional list of strings
- response_format: Optional atom (:text or :json)
- seed: Optional integer for deterministic responses
- stream: Optional boolean for streaming responses
- context: The action context containing state and other information
Returns
- } on success
- on failure
- Stream of chunks if streaming is enabled
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"}