Handwave is a thin wrapper around InstructorLite that makes it simpler to use vague handwaving in your apps.
It comes with 3 built-in providers (Handwave.OpenAI, Handwave.Claude and Handwave.Gemini) and behaviour to define your own.
Here’s its whole API surface:
- Use
llm_ifwhen you can’t come up with a regularif:
import Handwave.OpenAI
llm_if user_email, "looks suspicious?" do
{:error, :blocked}
else
create_user(user_email)
end
- Use
llm_rewritewhen you just need thatterm() -> 🧠🪄✨ -> stringfunction:
iex> llm_rewrite(
%Req.Response{status: 401, body: "session token expired"},
"Tell user what to do without technical details"
)
"Your session has expired. Please log in again to continue."
- Use
llm_routewhen you want LLM to just figure out what to do:
import Handwave.OpenAI
@impl Oban.Worker
def process(job) do
# do things
catch
kind, error ->
formatted = Exception.format(kind, error, __STACKTRACE__)
formatted
|> llm_route([:snooze, :cancel, :error], "Snooze if it makes sense to try later, cancel if it's a lost cause, otherwise just error")
|> case do
:snooze -> {:snooze, 60}
:cancel -> {:cancel, error}
_ -> {:error, formatted}
end
end
Have fun.
- Hex
- Repo






















