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
agents dsl elixir
Last synced: 9 days 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 (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-13T23:05:31.000Z (over 1 year ago)
- Last Synced: 2025-02-25T03:16:39.395Z (over 1 year ago)
- Topics: agents, dsl, elixir
- Language: Elixir
- Homepage:
- Size: 15.6 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
- OpenAi
need 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)
end
on_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
end
handle :info, {:task, :extract_tags, extracted} do
{:next_state, Map.put(data, :extracted, extracted)}
end
end
classification :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
""")
end
task :extract_title, user_input do
prompt("""
Extract title from this information: <%= user_input %>
""")
backend(API.Gemini)
end
task :extract_tags, user_input do
prompt("""
Extract tags from this information: <%= user_input %>
""")
backend(API.OpenAi)
end
end
end
```