Simatwa / python-tgpt

AI Chat in Terminal + Package + REST-API
https://python-tgpt.onrender.com
MIT License
106 stars 15 forks source link

Tearing on terminal #7

Closed sameedzahoor closed 9 months ago

sameedzahoor commented 9 months ago

I have been experiencing tearing on the terminal using python tgpt which has become worse with the latest update. The output on the terminal completely vanishes once the generation is complete. Maybe you need to lower the rate at which the generation occurs. Also maybe you could provide an option of saving the entire response (including markdown themes) to some buffer and then echoing the output all at once. (That's what the -w flag does in the original tgpt). I am using Xfce terminal. I checked the same on guake. Same issue so it's not terminal specific.

Simatwa commented 9 months ago

I think the recent update has fix that. Kindly confirm.

sameedzahoor commented 9 months ago

Yes it is slightly better now though the screen still flashes when a certain topic is enclosed in a rectangle as a heading. There is also another issue that if the cursor reaches the bottom of the terminal during generation, three red dots appear at the bottom and the screen does not automatically scroll up. (That is something that the orginal tgpt does.) Also can you rename the tpgt command to pytgpt because I want to keep both python-tgpt and the original tgpt on my system.

Simatwa commented 9 months ago

I bet everything is fine now.

sameedzahoor commented 9 months ago

The tearing is still quite bad at times although the output is not disappearing completely. The two dots are gone though. The auto scrolling of the output is now as expected.

Simatwa commented 9 months ago

What exactly do you mean by "Tearing"?

sameedzahoor commented 9 months ago

The screen flashes repeatedly when printing codeblocks or highlighling headings in large rectangles. I have switched printing in raw format by default for my own work and that has helped.

Simatwa commented 9 months ago

The challenge lies with the rendering of live updates in the click library. It tends to flash the entire screen before an update occurs. This is the rationale behind my decision to adopt ellipsis as the default vertical overflow behavior. Regrettably, there's limited room for improvement in this regard, except for the option of disabling streaming responses and then directing the complete responses to stdout.

sameedzahoor commented 9 months ago

The tearing is not that bad in the raw mode. You can try to disable streaming by allowing the user using the -w flag if he feels necessary.

sameedzahoor commented 9 months ago

I built a user interface using fzf for python-tgpt. Check it out and use it and send me feedback. https://github.com/sameedzahoor/szl

Simatwa commented 9 months ago

I built a user interface using fzf for python-tgpt. Check it out and use it and send me feedback. https://github.com/sameedzahoor/szl

Is a nice script. I find it useful.

Simatwa commented 9 months ago

The tearing is not that bad in the raw mode. You can try to disable streaming by allowing the user using the -w flag if he feels necessary.

With the recent update something like this $ pytgpt "More of that" -q -bi 0 -p fakeopen --raw -w will just stdout the response only.