Skip to content
/ gen Public

Simple command-line interface to Google Gemini large language models.

License

Notifications You must be signed in to change notification settings

jdevoo/gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

To use gen, you will need a valid Gemini API key set in the GEMINI_API_KEY environment variable.

Note

If you don't already have one, go to Google AI Studio to create a key.

Single-turn Examples

Plain text generation
$ gen dix noms de fleurs

At the command line, you may have to put the prompt inside double quotes to avoid confusing the shell
$ gen "a scheme function to compute the Levenshtein distance between two strings; only the code"

Pipe content into gen and save its output in a text file
$ cat cmd.go | gen -f - what does this code do? | tee report.txt

Obtain the token count
$ gen -t how many tokens would this prompt consume?

Parameterize prompts
gen -p a=1 -p b=2 "complete this sentence: replace {a} apple with {a} banana and {b} oranges for a good ..."

Set a system instruction from stdin and prompt from argument
echo "you understand english but always reply in french" | gen -s -f - ten names for flowers

Set a system instruction from file option and prompt from argument
gen -f french.sprompt ten names for flowers"

Set a system instruction from argument and enter chat
gen -c -s you understand english but always answer in German

Attach two files to the prompt and return total token count
gen -t -f ../twitter/img/123497680.jpg -f ../twitter/img/123406895.jpg what are the differences between these photos?

Enter chat mode to generate various SQL statements
cat classicmodels.sql | gen -f - -c

Generate an architecture decision record using a parameterized template
gen -f adr.sprompt -p certified="certified AWS Solution Architect Professional" an architecture decision record to help my organization decide between storage technologies for storing and accessing 10TB worth of time series data - please provide concrete examples and figures where possible

List known Gemini models by invoking tool
gen -tool list known generative models

Extract entities from text
w3m -dump https://lite.cnn.com/2024/07/27/asia/us-austin-trilateral-japan-south-korea-intl-hnk/index.html | gen -json -f - extract entities

System instruction and prompts as files from iterative Prisonner's Dilemma paper
gen -json -f pd.sprompt -f pd.prompt

Chain of thought
gen Please answer this question starting in two ways. First start with yes, then start with no and show your work. Afterwards determine which is correct. Is 3307 a prime number?

Generate sequence diagram from code using PlantUML system instruction
gen -f puml.sprompt -f ~/lib/Duke/duke-core/src/main/java/no/priv/garshol/duke/Duke.java sequence diagram of the main_ method in this file

Multi-turn Example

Generate a brief using an adapted version of Ali Abassi's prompt
gen -c -f brief.sprompt -f brief.prompt -p role="Sr. Business Analyst" -p department="ACME Technology Solutions" -p task="create a project brief" -p deliverable="project brief"

Usage

Usage: gen [options] <prompt>

Command-line interface to Google Gemini large language models
  Requires a valid GEMINI_API_KEY environment variable set.
  Content is generated by a prompt and optional system instructions.
  Use - to assign stdin as prompt argument or as attached file.

Options:
  -V    output model details, system instructions and chat history
        details include model name | maxInputTokens | maxOutputTokens | temp | top_p | top_k
  -c    enter chat mode after content generation
        type two consecutive blank lines to exit
        not supported on windows when stdin used
  -f value
        file to attach where value is the path to the file
        use extensions .prompt and .sprompt for user and system instructions respectively
        repeat for each file
  -h    show this help message and exit
  -json
        response in JavaScript Object Notation
  -m string
        generative model name (default "gemini-1.5-flash")
  -p value
        prompt parameter value in format key=val
        replaces all occurrences of {key} in prompt with val
        repeat for each parameter
  -s    treat argument as system instruction
        unless stdin is set as file
  -t    output total number of tokens
  -temp float
        changes sampling during response generation [0.0,2.0] (default 1)
  -tool
        invoke one of the tools {KnownModels,RetrieveAWSAccountIDs}
  -top_p float
        changes how the model selects tokens for generation [0.0,1.0] (default 0.95)
  -unsafe
        force generation when gen aborts with FinishReasonSafety
  -v    show version and exit

License

This project is licensed under the MIT License.

About

Simple command-line interface to Google Gemini large language models.

Resources

License

Stars

Watchers

Forks

Packages

No packages published