Hacker News new | ask | show | jobs
Show HN: GenAI Prompts as "Native" Programs (promptcmd.sh)
1 points by tgalal 145 days ago
Lately I've seen several projects for templating and executing prompts. However they all go along the lines of

  $ executor prompt_file_or_name
which didn't exactly fit my "taste".

I figured one could use the same trick like busybox, where you can detect if your binary is being executed via a different name (symlink). The symlink name is treated as the promptname, and arguments are generated from a schema defined in the prompt template.

So now instead of:

  # Using https://github.com/chr15m/runprompt
  echo '{"words": 300, "text": "some long text"}' | ./runprompt summarize.prompt
  # Or using https://github.com/simonw/llm
  echo "some long text" | llm -t summarize -p words 300
You get:

  echo "some long text" | summarize --words 300
And of course with documented arguments and so on:

  summarize --help
  
  Usage: summarize [OPTIONS] --words <words> --text <text>
  
  Prompt inputs:
        --words <words>  Maximum number of words
        --text <text>    The text to summarize, defaults to stdin
That was the starting point, then things escalated and suddenly there is load balancing, caching, execution via shebang and other (IMO) neat features :).

Happy to get feedback and ideas.

Github: https://github.com/tgalal/promptcmd/

Documentation: https://docs.promptcmd.sh/

Examples: https://promptcmd.sh/lib/