martosaur

martosaur

Handwave - just handwave any problem with LLM

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:

  1. Use llm_if when you can’t come up with a regular if:
import Handwave.OpenAI

llm_if user_email, "looks suspicious?" do
  {:error, :blocked}
else
  create_user(user_email)
end
  1. Use llm_rewrite when you just need that term() -> 🧠🪄✨ -> string function:
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."
  1. Use llm_route when 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.

https://github.com/martosaur/handwave

Most Liked

martosaur

martosaur

That were exactly my thoughts that led me to making this package, but ultimately, I came to realization that this is a useful library (that’s why I released it). Structured outputs for LLMs enable embedding small bits of intelligence in conventional application code and at this point I can’t help but admit that sometimes this is useful. Admittedly, examples in the readme are silly, because they have to be small and because I chose a playful tone for the library as a way to cope with new reality. But in real life I use this type of stuff to determine, for example, if user wants to do a “broad” search or “focused” one and trigger different search pipeline based on perceived intent.

I agree that this can be an absolutely cursed way to do things in the wrong hands. I’m not too worried though as it seems like nobody it writing code by hand these days and Claude won’t use this library.

FlyingNoodle

FlyingNoodle

llm_if user_email, "looks suspicious?" do

llm_if ← this is a joke right? Are we really at that point?

DaAnalyst

DaAnalyst

I actually like this, specially the llm_rewrite.

llm_if could be useful for non- too-deterministic cases, such as branching in video games.

Where Next?

Popular in Announcing Top

asiniy
Hey there! I wrote a download elixir package which does exactly what its name about - an easy way to download files. I saw solutions ab...
New
dbern
I’m excited to announce that TaxJar has developed and open-sourced DateTimeParser. We developed it because we found a need to parse user ...
New
pkrawat1
Presenting Aviacommerce, open source e-commerce platform in Elixir Aviacommerce is an open source e-commerce platform in Elixir. We at...
New
devonestes
Introducing assertions, the library that helps you write really great test assertions! GitHub: GitHub - devonestes/assertions: Helpful a...
New
brainlid
LangChain is short for Language Chain. An LLM, or Large Language Model, is the “Language” part. This library makes it easier for Elixir a...
New
alisinabh
Hey everyone i’ve developed a library for Jalaali calendar for elixir which supports converting Gregorian dates to Jalaali and vice vers...
New
cjen07
parameterized pipe in elixir: |n> edit: negative index in |n> and mixed usage with |> are supported example: use ParamPipe ...
New
Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New
versilov
Could not wait for the missing Elixir ML libraries to appear, so, I wrote one myself, taking https://github.com/sdwolfz/exlearn as a foun...
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New

Other popular topics Top

New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

We're in Beta

About us Mission Statement