https://github.com/elchemista/agent_dsl
DSL for creating Ai Agents using :gen_statem with streaming response from Replicate,OpenAi,Gemini
https://github.com/elchemista/agent_dsl
Last synced: 3 months ago
JSON representation
DSL for creating Ai Agents using :gen_statem with streaming response from Replicate,OpenAi,Gemini
- Host: GitHub
- URL: https://github.com/elchemista/agent_dsl
- Owner: elchemista
- Created: 2025-02-12T20:17:58.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2025-02-12T20:32:10.000Z (4 months ago)
- Last Synced: 2025-02-12T21:30:22.793Z (4 months ago)
- Language: Elixir
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AgentDsl
# VERY EXPERIMENTAL do not use anywhere!
### API will change, every day, maybe even two times a day.### Backend API
- Replicate
- Gemini
- OpenAineed keys for each API, add to .env
```bash
export REPLICATE_API_KEY=xxxx
export GEMINI_API_KEY=xxxx
export OPENAI_API_KEY=xxxx
```### Example DSL
```elixir
defmodule MyAgent do
use Agent.DSL
alias Agent.API.{Replicate, Gemini, OpenAi}agent do
initial_state(:ask_intro)
initial_data(%{name: "Tao"})state :ask_intro do
prompt("""
Ask user what job he want to create, using this information: <%= data["name"] %>}
""")backend(API.Replicate)
on_enter do
ask(%{}, prompt)
endon_event :cast, {:user_input, user_input} do
run_task(extract_title(user_input))
run_task(extract_tags(user_input))classify check_if_user_write_all(user_input) do
":repeat" -> {:keep_state, data}
":stop" -> {:stop, data}
_ -> ask(%{}, prompt)
end
endhandle :info, {:task, :extract_tags, extracted} do
{:next_state, Map.put(data, :extracted, extracted)}
end
endclassification :check_if_user_write_all, user_input do
backend(API.Gemini)prompt("""
Classify this input: <%= user_input %>answer if user want to repeat -> :repeat
answer if user want to go next step -> :next
answer if user want to stop -> :stop
""")
endtask :extract_title, user_input do
prompt("""
Extract title from this information: <%= user_input %>
""")backend(API.Gemini)
endtask :extract_tags, user_input do
prompt("""
Extract tags from this information: <%= user_input %>
""")backend(API.OpenAi)
end
end
end
```