Skip to content

A CLI application to run Prompt Markup Language scripts

License

Notifications You must be signed in to change notification settings

narenaryan/promptml-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

promptml-cli

A CLI application to run PromptML scripts against LLMs.

Installation

pip install --upgrade promptml-cli

Demo

asciicast

Usage

promptml-cli --help

usage: promptml-cli [-h] -f FILE [-m MODEL] [-s {xml,json,yaml}] [-p {openai,google}] [--stream] [--raw]

A Command Line Interface (CLI) tool to run Prompt Markup Language (PromptML) files with popular Generative AI models

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  Path to the PromptML(.pml) file
  -m MODEL, --model MODEL
                        Model to use for the completion
  -s {xml,json,yaml}, --serializer {xml,json,yaml}
                        Serializer to use for the completion. Default is `xml`
  -p {openai,google}, --provider {openai,google}
                        GenAI provider to use for the completion. Default is `openai`
  --stream              Stream chunks for the GenAI response. Default is non-streaming response.
  --raw                 Return raw output from LLM (best for saving into files or piping)

For more details of composing PromptML files, visit: https://promptml.org/

Example

  1. Create a PromptML file character.pml with the following content:
@prompt
    @context
        You are a millitary general in Roman army.
    @end

    @objective
        Describe a regular day in your life.
    @end

    @instructions
        @step
            Be cheeky and sarcastic.
        @end
    @end

    @category
        Simulation
    @end
@end

See PromptML documentation for more details about the syntax.

  1. Set your OpenAI API key as an environment variable:
export OPEN_AI_API_KEY=your-openai-api-key

or if you are using Google GenAI.

export GOOGLE_API_KEY=your-google-api-key
  1. Run the PromptML file with the following command in terminal:
promptml-cli -f character.pml -m gpt-4o

You will see the respective output on terminal:

Ah, so you want a glimpse into the life of a Roman general, do you? Well, let me spin you a tale, dripping with sarcasm and cheeky remarks, because obviously, my life is a walk in the park. Shall we?

The day usually starts with the soothing sounds of soldiers clanging their swords and shields together at some ungodly hour. Rather than waking up to the gentle cooing of doves, I get to hear the charming war cries of recruits who still can't tell their gladius from their left foot. Delightful, isn't it?

After I drag myself out of what I'm convinced is a sack filled with rocks they call a bed, it's straight to the strategy tent. Here, I enjoy the riveting discussions about which barbarian horde is threatening our borders this week. It's like choosing the lesser of two evils: invasions from the north or mutiny from the ranks. Decisions, decisions!

Next on the agenda is overseeing training. Oh yes, I just love watching greenhorns stumble through basic drills. The way they handle their weapons – you'd think a lopsided stick had suddenly become the deadliest thing in their hands. But hey, a general's got to humor them, right?

Then there's the daily feast of dried meat and stale bread, washed down with wine that's likely been used as paint thinner. Ah, the joys of Roman culinary delights. I'm sure Bacchus himself is weeping with laughter somewhere.

Afternoons are reserved for dealing with the Senate's missives, those beautifully crafted scrolls filled with ‘helpful’ suggestions and veiled threats. It's like mail time with a hint of doomsday. And who can forget the thrill of addressing the legion, trying to maintain morale while standing in armor that weighs more than some of the new recruits?

As evening falls, I get to review the day's progress with my centurions, who conveniently bring me the freshest of problems right before bedtime. If I’m lucky, I'll dodge an assassination attempt or two – keeps life exciting, don’t you think?

Finally, I retire for the night, eager to wake up and do it all over again. Really, what's not to love? So there you have it! Just another average day in the life of a Roman general – a blend of strategy, sarcasm, and just a dash of masochism.

Time taken: 6.006012916564941 seconds

Streaming Response

You can also stream the response from the GenAI model by using the --stream flag. This will stream the response in chunks as they are generated by the model.

promptml-cli -f character.pml -p google --stream

Raw Output

You can also get the raw output from the GenAI model by using the --raw flag. This will return the raw output from the model without any formatting.

promptml-cli -f character.pml -p google --raw

Note: Raw output is useful when you want to save the output to a file or pipe it to another command.

TODO

  • Add support for Claude, Cohere & A21 Labs GenAI models
  • Add tests