News for hackers. Stuff that matters.

Show HN: Llm2sh – Translate plain-language requests into shell commands

https://github.com/randombk/llm2sh

This is my take on the common "use llms to generate shell commands" utility. Emphasis is placed on good CLI UX, simplicity, and flexibility.

`llm2sh` supports multiple LLM providers and lets LLMs generate multi-command sequences to handle complex tasks. There is also limited support for commands requiring `sudo` and other basic input.

I recommend using Groq llama3-70b for day-to-day use. The ultra-low latency is a game-changer - its near-instant responses helps `llm2sh` integrate seamlessly into day-to-day tasks without breaking you out of the 'zone'. For more advanced tasks, swapping to smarter models is just a CLI option away.

( 22 comments | 11 points | on HN )
Re:Show HN: Llm2sh – Translate plain-language requests into ... by conkeisterdoor on Wednesday July 17, 2024 @11:49PM (#40992330)
This looks great! I would use this if you had a dispatcher for using a custom/local OpenAI-compatible API like eg llama.cpp server. If I can make some time I'll take a stab at writing one and submit a PR :)
Re:Show HN: Llm2sh – Translate plain-language requests into ... by RandomBK on Wednesday July 17, 2024 @11:52PM (#40992345)
Already exists :)

Set the `local_uri` setting in the configuration (`llm2sh --setup`), and either pass `-m local` on the CLI or set `"default_model": "local"` in the config.

PRs are always welcome.

Re:Show HN: Llm2sh – Translate plain-language requests into ... by conkeisterdoor on Thursday July 18, 2024 @12:21AM (#40992495)
Thanks so much!
Re:Show HN: Llm2sh – Translate plain-language requests into ... by yjftsjthsd-h on Wednesday July 17, 2024 @11:40PM (#40992288)
Some really nice things:

+ GPLv3

+ Defaults to listing commands and asking for confirmation

+ Install is just "pip install"

+ Good docs with examples

Is there a way to point at an arbitrary API endpoint? IIRC llama.cpp can do an OpenAPI compatible API so it should be drop in?

Re:Show HN: Llm2sh – Translate plain-language requests into ... by RandomBK on Wednesday July 17, 2024 @11:50PM (#40992339)
I'm glad you like it! The whole point is to have a simple no-frills clean CLI experience.

> Is there a way to point at an arbitrary API endpoint?

Yes. Set the `local_uri` setting in the configuration (`llm2sh --setup`), and either pass `-m local` on the CLI or set `"default_model": "local"` in the config.

Re:Show HN: Llm2sh – Translate plain-language requests into ... by yjftsjthsd-h on Wednesday July 17, 2024 @11:57PM (#40992367)
Oh, nice; thanks:)
Re:Show HN: Llm2sh – Translate plain-language requests into ... by llagerlof on Thursday July 18, 2024 @01:10AM (#40992672)
Nice tool. I am using ai-shell for that purpose.

https://github.com/BuilderIO/ai-shell

Re:Show HN: Llm2sh – Translate plain-language requests into ... by francisduvivier on Thursday July 18, 2024 @01:15AM (#40992696)
Wonder how this compares to open interpreter.
Re:Show HN: Llm2sh – Translate plain-language requests into ... by fire_lake on Thursday July 18, 2024 @02:42AM (#40993057)
Would consider rewriting in a language that is more portable? Ideally this would be a single binary, excluding the models!
Re:Show HN: Llm2sh – Translate plain-language requests into ... by RandomBK on Thursday July 18, 2024 @03:21AM (#40993266)
I've no plans for it myself, but that sounds like an interesting project! It should be fairly easy to hack together. The actual logic itself is just a few dozen lines of glue code around a single HTTP POST request.
Re:Show HN: Llm2sh – Translate plain-language requests into ... by Y_Y on Thursday July 18, 2024 @07:37AM (#40994645)
There are plenty of variations on this tool around, it would be nice to see a comparison.
Re:Show HN: Llm2sh – Translate plain-language requests into ... by visarga on Thursday July 18, 2024 @10:19AM (#40995805)
I remember at least 5 of them discussed right here on HN
Re:Show HN: Llm2sh – Translate plain-language requests into ... by padolsey on Thursday July 18, 2024 @08:31AM (#40994979)
Cool! I’m experimenting with something like this that uses docker containers to ensure it’s sandboxed. And, crucially, rewindable. And then I can just let it do ~whatever it wants without having to verify commands myself. Obviously it’s still risky to let it touch network resources but there’s workarounds for that.
Re:Show HN: Llm2sh – Translate plain-language requests into ... by freedomben on Thursday July 18, 2024 @09:50AM (#40995578)
What is the (hoped for) future after your experiments? Are you hoping to gain enough confidence/refinement on it that you can run it on you main system? Or just hoping to serve curisioty? (I could see myself doing either, so just curious)
Re:Show HN: Llm2sh – Translate plain-language requests into ... by padolsey on Thursday July 18, 2024 @08:15PM (#41000950)
I wouldn't be happy to run it containerless, per se, but within docker or on a remote spun-up box it's fine. I think it's mostly something to play with for now, but I'll eventually build it into a couple of AI platforms I run, just to help with amorphous tasks and more deterministic outputs with math and data.
Re:Show HN: Llm2sh – Translate plain-language requests into ... by amelius on Thursday July 18, 2024 @08:38AM (#40995021)
Does it understand commands such as "get this Nvidia driver to work"?
Re:Show HN: Llm2sh – Translate plain-language requests into ... by elashri on Thursday July 18, 2024 @09:53AM (#40995602)
Not sure that it actually read any context from your environment. GitHub copilot CLI does not. So if you want it to answer something like that, then you will need to tell it exactly what "this Nvidia driver" is actually is.
Re:Show HN: Llm2sh – Translate plain-language requests into ... by visarga on Thursday July 18, 2024 @10:19AM (#40995798)
I think it's one-round, not interactive. So it can't do complex tasks
Re:Show HN: Llm2sh – Translate plain-language requests into ... by causal on Thursday July 18, 2024 @09:53AM (#40995605)
This looks good.

I created something similar using blade a while back, but I found that using English to express what I want was actually really inefficient. It turns out that for most commands, the command syntax is already a pretty expressive format.

So nowadays I'm back to using a chat UI (Claude) for the scenarios where I need help figuring out the right command. Being able to iterate is essential in those scenarios.

Re:Show HN: Llm2sh – Translate plain-language requests into ... by MuffinFlavored on Thursday July 18, 2024 @09:55AM (#40995624)
How much time does this gain you from the perspective of "you have to double check its output and hope it didn't make a mistake"?
Re:Show HN: Llm2sh – Translate plain-language requests into ... by visarga on Thursday July 18, 2024 @10:18AM (#40995792)
Doesn't save time, but it's a nice experience. Sometimes you get exposure to something you didn't know, other times it makes the boring stuff less annoying.
Re:Show HN: Llm2sh – Translate plain-language requests into ... by xgfh on Friday July 19, 2024 @09:31AM (#41006384)
This is a fascinating tool! `llm2sh` looks like it can save a lot of time and hassle for those who often find themselves Googling shell commands. The fact that it supports multiple LLMs and offers a 'YOLO mode' is both exciting and a bit scary . I'm curious, has anyone tried integrating it with more complex workflows? Any stories of it saving the day (or causing chaos)?