drorm / gish

GPT command line
MIT License
62 stars 7 forks source link

Prepend a prompt when passing a file #15

Closed ManveerBhullar closed 1 year ago

ManveerBhullar commented 1 year ago

gish "Return the first 5 lines only, nothing else' -i 10LinePoem.txt or gish -i 10LinePoem.txt "Return the first 5 lines only , nothing else"

It would be dope if a functionality like this could be implemented. Would be helpful to string with -s to summarize notes, manipulate documents, etc.

drorm commented 1 year ago

How about using -p flag? Put the prompt in a file and just do

gish -i 10LinePoem.txt -p summarize.txt
ManveerBhullar commented 1 year ago

Seems like an unneccesary step to first save a prompt to a file then feed it in, especially when that prompt is changing often. Its also created files on the filesystem for something that should be ephemeral. For added context, a typical use case could be like the following.

gish -i 10LinesOfPoem.txt "Rewrite this in the style of shakespeare"

gish -i 10LinesOfPoem.txt "Rewrite this in the style of Lord Byron"

I use this currently as a work around https://gist.github.com/ManveerBhullar/4abc087fc361ee5c0b7375174a9132fb , but i havent bothered trying to make it so it works with more flags, so its not a complete solution.

drorm commented 1 year ago

Try this

gish -p 10LinesOfPoem.txt "Rewrite this in the style of shakespeare"

I realize it's a bit confusing, prompt <--> instructions, but it works :-).

Having said that, I do think I need to go back and look at the way different flags interact with each other. It might make sense to have multiple -i or combine -i with a text prompt. Though, personally, for complex cases, I just have a "input" file, and in there I can just "#import" as many files as I want and change the text in the file and then just run

gish -i input
ManveerBhullar commented 1 year ago

gish -p 10LinesOfPoem.txt "Rewrite this in the style of shakespeare"

This is great. Thanks, I can remove that ugly function from my .bashrc now :)

Have you thought about combining -i and -p, and support arbitrary number of file or string inputs?

ie

gish -p file1 file2 file3 "tell me about these files" "in a rhyming poem"

drorm commented 1 year ago

It does seem like -i and -p should coexist as well as just args on the command line like ...

gish -p file1 -i files tell me about these files

Having said that I asked gish and it provided this simple solution :-).

{ echo "tell me about these files" "in a rhyming poem"; cat package.json; } | gish

and it responded

In this file there's lots to see,
From "main" to "license" and "type" to "exports" you see.
The "scripts" section includes "start" and "test",
And "dev" and "prd" are among the rest.
There's "devDependencies" and "dependencies" too,
With "esbuild" and "playwright" joining the crew.
And "pkg" stands out with its targets and options,
Making sure the file runs on different versions.
The "bin" section makes "gish" the star,
With "dist/index.js" as its shining arm.
...

I'd better stop now. It's too much fun.