Skip to content

Commit

Permalink
Remove indent on markdown for easy copy/paste
Browse files Browse the repository at this point in the history
Reduce size of cli prompt
  • Loading branch information
CrustyCode committed Nov 11, 2024
1 parent 5f686f9 commit 86a948c
Show file tree
Hide file tree
Showing 2 changed files with 681 additions and 7 deletions.
11 changes: 4 additions & 7 deletions gptcli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@
from rich.console import Console
from rich.live import Live
from rich.markdown import Markdown
from .markdown import CustomMarkdown
from rich.text import Text

from gptcli.session import (ALL_COMMANDS, COMMAND_CLEAR, COMMAND_QUIT,
COMMAND_RERUN, ChatListener, InvalidArgumentError,
ResponseStreamer, UserInputProvider)

TERMINAL_WELCOME = """
Hi! I'm here to help. Type `:q` or Ctrl-D to exit, `:c` or Ctrl-C and Enter to clear
the conversation, `:r` or Ctrl-R to re-generate the last response.
To enter multi-line mode, enter a backslash `\\` followed by a new line.
Exit the multi-line mode by pressing ESC and then Enter (Meta+Enter).
Try `:?` for help.
Assistant:
"""


Expand All @@ -43,7 +40,7 @@ def print(self, text: str):
self.current_text += text
if self.markdown:
assert self.live
content = Markdown(self.current_text, style="green")
content = CustomMarkdown(self.current_text, style="green")
self.live.update(content)
self.live.refresh()
else:
Expand Down Expand Up @@ -84,7 +81,7 @@ def __init__(self, markdown: bool):

def on_chat_start(self):
console = Console(width=80)
console.print(Markdown(TERMINAL_WELCOME))
console.print(CustomMarkdown(TERMINAL_WELCOME))

def on_chat_clear(self):
self.console.print("[bold]Cleared the conversation.[/bold]")
Expand Down
Loading

0 comments on commit 86a948c

Please sign in to comment.