npiv / chatblade

A CLI Swiss Army Knife for ChatGPT
GNU General Public License v3.0
2.58k stars 92 forks source link

Bad formatting in code blocks #94

Closed danielj-n closed 2 months ago

danielj-n commented 2 months ago

For some reason some of the formatting in my code blocks is off.

I am using chatblade -s -i on gpt-4o however I had similar issues on 3.5 recently too.

Version is chatblade 0.6.2 on archlinux from the package extra/chatblade. I'm using bash in the alacritty terminal emulator.

The most common and easily reproducible one happens whenever I request bash code that uses "--" ie. give me some examples of linux commands using --. This returns badly formatted results like this:

image

From looking at the stream text before the formatting it looks like chatgpt formatted it correctly

image

Does anyone know why this might be?

danielj-n commented 2 months ago

I did some digging and unfortunately I think this might be an issue with the newly added latex formatting feature (-- in latex becomes a "em dash"). I commented out msg = format_latex(msg) in printer.py and it seems like that removed the issue.

image

Would the easiest solution just be to prevent latex formatting in code blocks entirely? I don't see why it ever would need to be in code blocks.

danielj-n commented 2 months ago

Wrote a small fix, it seems to work. It is a little messy since it uses string replacements. Let me know how I can improve it.

image image

This fix also means latex is no longer formatted in code blocks when chatgpt is writing latex in code blocks. But I think this is actually desirable behavior since it tends to only stick things in codeblocks that are meant to be unformatted.

image
npiv commented 2 months ago

fixed in 0.6.3

pip has it, homebrew takes a few hours

Thx a lot, if you do see any more issues let me know. As mentioned would consider just making latex step opt in.