Simatwa / python-tgpt

AI Chat in Terminal + Package + REST-API

Home Page:https://python-tgpt.onrender.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Standard input and standard output

sameedzahoor opened this issue · comments

The output of the command should not be printed with the title AI response and framed by default. This is because one might want to pipe the output text in a script. You could however add a flag to print the output as such.

The command tgpt2 like tgpt should ideally take in inputs from standard input also and print results to standard output.

Also it would be wise if the default behaviour is similar to tgpt and we could write something like:
tgpt2 "Hello"
without having to type the command generate and -P flags. It's really inconvenient typing it all again and again.

The other default commands of tgpt like the --quiet flag and -w and -c options should also be mimicked.

I really like the idea of controlling parameters like temperature and brave keys and all. I think tgpt2 has the potential to be a really nice project.

Nice idea folk.
On the first issue; consider it done - just a matter of time.
On the second and third one, I think there's a workaround. alias tgpt2="tgpt2 generate -P " $@. Preferably in your ~/.zshrc

  • I preferred click over the native argparse because of scalability just incase a new feature will be introduced. (Less nested ifs)

On the fourth one, I like it; we gonna work on that.

Yes an alias does work but the behaviour is not always simple.
For example right now one can do something like
echo "Hello" | tgpt2 generate which works and have an alias tgpt2="tgpt2 generate ".
However, that would require one to type the -P flag the rest of the time (or your alias). I think the -P flag is unnecessary. The prompt should ideally be the default argument with no need of typing -P.

Small fixes here.

Previous Current
$ tgpt generate -P "Hello there" $ tgpt "Hello there"

New flags for generate command:

Flag Function Interactive Mode Equilavent
-w/--whole None : (Prompt not altered/modified) None - (Default)
-c/--code Optimize prompt for code generation code
-s/--shell Optimize prompt for shell command generation shell

Note : For interactive mode just type the command followed by prompt e.g shell Scan SMB vulnerability or code Number guessing game in Python

@sameedzahoor Confirm that everything good.

Also most important we need to remove the frame around the output and also the title "AI Response". We can't even copy the code properly because of it.
Just checked the edits and they look ok. Maybe we would need to change the name of the file tgpt2 to tgpt or pytgpt.

Just append -q or --quiet to either of the two commands to get rid of the frame. And then on the interactive prompt make use of copy_this for copying whole previous response or copy_this code to copy only the code-blocks.

On the file name; recheck.

I tried out piping standard input into tgpt, but it fails. In the original tgpt we can do echo "Hello" | tgpt which is equivalent to tgpt "Hello". This allows standard input to be piped into tgpt which can be useful in scripts.
Also when using the -w flag the entire generated text should be saved in a variable first and then printed all at once. That's what whole text means here.
Other than that I find the changes amazing. Good work!

Unfortunately, the best I could deliver is this one echo "Hello there" | tgpt generate. I find it hard to explain why, but am so sure if you dig deep in the repo, you would actually get the answer. It was a pleasure addressing this thread. Good night folk.