Coder Social home page Coder Social logo

Render markdown output about shell_gpt HOT 9 CLOSED

volkov avatar volkov commented on June 12, 2024 1
Render markdown output

from shell_gpt.

Comments (9)

TheR1D avatar TheR1D commented on June 12, 2024 2

It is possible to pipe output of sgpt to glow or any other markdown reader (which supports stdin).

sgpt "how to zip all files in current folder" | glow

from shell_gpt.

jeanlucthumm avatar jeanlucthumm commented on June 12, 2024 1

I found the DISABLE_STREAMING option and at the very least, it's possible to output markdown if that's enabled:

output.mov

Code: jeanlucthumm@eed0f7e

I'm not sure how I feel about the long waiting times though.

Other than that, I think you would need a full screen TUI to pull this off because you have to clear and repain the markdown file as words come in, but only from the current line down. The only thing I found was clearning the entire screen using console.clear(), and while that works, you lose all your history.

To deal with the streaming, one option is to detect beginning of special blocks, like a code block, and then automatically append a closing statement until we get the actual one from the llm. We'd have to identify all such blocks.

^ This isn't actually neccessary, it turns out that Markdown from rich still displays fine if there's no closing backicks fo a code block

from shell_gpt.

volkov avatar volkov commented on June 12, 2024

True, at least for latest glow versions (1.4.0 does not support stdin).

Piping to glow makes outupt more readable, but I have to wait till end of generation to see anything.

from shell_gpt.

David-Else avatar David-Else commented on June 12, 2024

How about https://github.com/swsnr/mdcat for full output, or https://github.com/sharkdp/bat to get some colour highlighting? (bat is batcat in Debian)

This works, but for some reason there is no colour, do I need some --color type option?:

sgpt "show me some markdown that contains all markdown features" | batcat

from shell_gpt.

jeanlucthumm avatar jeanlucthumm commented on June 12, 2024

https://rich.readthedocs.io/en/stable/markdown.html

^ python lib for markdown rendering with code syntax highlighting, and it looks like it's already a dependency of this project:

"rich >= 13.1.0, < 14.0.0",

A lot of my use case is with the --repl flag so piping is not an option

from shell_gpt.

jeanlucthumm avatar jeanlucthumm commented on June 12, 2024

The line that prints messages seems to be this one:

typer.secho(word, fg=self.color, bold=True, nl=False)

Gonna try to change it to the Rich markdown handler and see what happens

I guess one issue is that the words stream in, and Rich requires a full text ready?

from shell_gpt.

jeanlucthumm avatar jeanlucthumm commented on June 12, 2024

To deal with the streaming, one option is to detect beginning of special blocks, like a code block, and then automatically append a closing statement until we get the actual one from the llm. We'd have to identify all such blocks.

Another consideration is how slow the markdown render is. It has to fully complete for every word streamed in which is multiple times per second.

from shell_gpt.

julian-hoch avatar julian-hoch commented on June 12, 2024

I use this alias:

sgpt_glow_replace() {
tmpfile=$(mktemp)
sgpt "$@" | tee $tmpfile
clear
cat $tmpfile | glow -
rm $tmpfile
}
alias s='sgpt_glow_replace'

from shell_gpt.

gwpl avatar gwpl commented on June 12, 2024

sounds like invitaiton for --glow and --no-glow options! (and default in config file "DEFAULT_GLOW=true|false"

from shell_gpt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.