Skip to content

Commit a7d2c0a

Browse files
committed
Apply code-theming in quiet mode
1 parent 5cc5ed2 commit a7d2c0a

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

tgpt/console.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,20 @@ def default(self, line):
336336
os.system(line[2:])
337337
else:
338338
try:
339-
busy_bar.start_spinning()
340-
generated_response = self.bot.chat(line, stream=True)
341339
if self.quiet:
340+
generated_response = self.bot.chat(line, stream=True)
342341
busy_bar.stop_spinning()
343342
console_ = Console()
344343
with Live(console=console_, refresh_per_second=16) as live:
345344
for response in generated_response:
346345
live.update(
347-
Markdown(response) if self.prettify else response
346+
Markdown(response, code_theme=self.code_theme)
347+
if self.prettify
348+
else response
348349
)
349350
else:
351+
busy_bar.start_spinning()
352+
generated_response = self.bot.chat(line, stream=True)
350353
busy_bar.stop_spinning()
351354
stream_output(
352355
generated_response,
@@ -431,7 +434,7 @@ def tgpt2_():
431434
@click.option(
432435
"-ct",
433436
"--code-theme",
434-
help="Theme for displaying response",
437+
help="Theme for displaying codes in response",
435438
type=click.Choice(rich_code_themes),
436439
default="monokai",
437440
)
@@ -525,7 +528,7 @@ def interactive(
525528
@click.option(
526529
"-ct",
527530
"--code-theme",
528-
help="Theme for displaying response",
531+
help="Theme for displaying codes in response",
529532
type=click.Choice(rich_code_themes),
530533
default="monokai",
531534
)
@@ -597,11 +600,9 @@ def generate(
597600
"""Generate a quick response with AI (Default)"""
598601
bot = Main(max_tokens, temperature, top_k, top_p, model, brave_key, timeout)
599602
prompt = Optimizers.code(prompt) if code else prompt
600-
prompt = Optimizers.shell_command if shell else prompt
601-
if quiet:
602-
print(bot.bot.chat(prompt))
603-
return
603+
prompt = Optimizers.shell_command(prompt) if shell else prompt
604604
busy_bar.spin_index = busy_bar_index
605+
bot.quiet = quiet
605606
bot.code_theme = code_theme
606607
bot.color = font_color
607608
bot.prettify = prettify
@@ -615,9 +616,7 @@ def main():
615616
and args[1] not in ["interactive", "generate"]
616617
and not "--help" in args
617618
):
618-
sys.argv.insert(
619-
1, "generate"
620-
) # Just a hack to make 'generate' a default command
619+
sys.argv.insert(1, "generate") # Just a hack to make 'generate' default command
621620
tgpt2_()
622621

623622

0 commit comments

Comments
 (0)