### Install Jidoka dependency Source: https://hexdocs.pm/jidoka Add the Jidoka package to your Elixir project dependencies. ```elixir def deps do [ {:jidoka, "~> 1.0.0-beta.1"} ] end ``` -------------------------------- ### Fetch and compile dependencies Source: https://hexdocs.pm/jidoka Run these commands in your terminal to download and compile the project dependencies. ```bash mix deps.get mix compile ``` -------------------------------- ### Inspect agent prompts and configuration Source: https://hexdocs.pm/jidoka Use preflight to view the assembled prompt or inspect to view the compiled agent specification without contacting the model provider. ```elixir {:ok, preflight} = Jidoka.preflight(MyApp.Assistant, "What can you help me with?") preflight.prompt #=> %{ #=> model: "openai:gpt-4o-mini", #=> messages: [ #=> %{role: :system, content: "Answer clearly and briefly."}, #=> %{role: :user, content: "What can you help me with?"} #=> ], #=> operations: [], #=> result: nil, #=> memory: nil, #=> context: %{}, #=> generation: %{temperature: 0.0, max_tokens: 500}, #=> loop_index: 0 #=> } preflight.timeline #=> [ #=> %{ #=> event: :prompt_assembled, #=> phase: :assemble_prompt, #=> category: :workflow, #=> status: :completed, #=> agent_id: "assistant", #=> loop_index: 0, #=> ... #=> } #=> ] ``` ```elixir Jidoka.inspect(MyApp.Assistant) #=> %{ #=> kind: :agent, #=> module: "MyApp.Assistant", #=> spec: %{ #=> id: "assistant", #=> model: "openai:gpt-4o-mini", #=> instructions: "Answer clearly and briefly.", #=> operations: [], #=> controls: %{ #=> max_turns: nil, #=> timeout_ms: nil, #=> inputs: [], #=> operations: [], #=> outputs: [] #=> } #=> }, #=> plan: %{ #=> spec_id: "assistant", #=> workflow_profile: :tool_loop, #=> max_model_turns: 8, #=> timeout_ms: 30000, #=> phases: [ #=> :assemble_prompt, #=> :plan_model_effect, #=> :apply_model_result, #=> :plan_operation_effects, #=> :apply_operation_results #=> ] #=> } #=> } ``` -------------------------------- ### Export provider API keys Source: https://hexdocs.pm/jidoka Set your LLM provider API key as an environment variable before running agents. ```bash export OPENAI_API_KEY=... # or export ANTHROPIC_API_KEY=... ``` -------------------------------- ### Define a Jidoka agent Source: https://hexdocs.pm/jidoka Create an agent by using the Jidoka.Agent module and defining the assistant configuration. ```elixir defmodule MyApp.Assistant do use Jidoka.Agent agent :assistant do model "openai:gpt-4o-mini" instructions "Answer clearly and briefly." end end ``` -------------------------------- ### Run a chat interaction Source: https://hexdocs.pm/jidoka Execute a chat request using the agent module directly or via the Jidoka facade. ```elixir {:ok, text} = MyApp.Assistant.chat("What can you help me with?") ``` ```elixir {:ok, text} = Jidoka.chat(MyApp.Assistant, "What can you help me with?") ``` -------------------------------- ### Define a Jidoka Action and Agent Source: https://hexdocs.pm/jidoka Defines a custom action with a schema and integrates it into an agent using the tools macro. ```elixir defmodule MyApp.LocalTime do use Jidoka.Action, name: "local_time", description: "Returns the local time for a city.", schema: Zoi.object(%{city: Zoi.string() |> Zoi.default("Chicago")}) @impl true def run(params, _context) do city = Map.get(params, :city) || Map.get(params, "city") || "Chicago" {:ok, %{city: city, time: "09:30"}} end end defmodule MyApp.TimeAgent do use Jidoka.Agent agent :time_agent do model "openai:gpt-4o-mini" instructions "Use local_time when the user asks for the time." end tools do action MyApp.LocalTime end end ``` -------------------------------- ### Retrieve Full Turn Details Source: https://hexdocs.pm/jidoka Uses turn/3 to access detailed turn information including events, journal results, and usage metrics. ```elixir {:ok, result} = Jidoka.turn(MyApp.TimeAgent, "What time is it in Chicago?") result.content result.usage result.events result.journal.results ``` -------------------------------- ### Execute Agent Chat Source: https://hexdocs.pm/jidoka Performs a simple chat interaction with the defined agent. ```elixir {:ok, text} = MyApp.TimeAgent.chat("What time is it in Chicago?") ``` -------------------------------- ### Manage Conversation Sessions Source: https://hexdocs.pm/jidoka Maintains multi-turn state using Jidoka.Session to persist context across multiple chat calls. ```elixir {:ok, session} = Jidoka.session(MyApp.Assistant, "demo-conversation") {:ok, session, text} = Jidoka.chat(session, "Remember that my team is called Platform.") {:ok, session, text} = Jidoka.chat(session, "What is my team called?") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.