1212import re
1313import sys
1414import platform
15+ import datetime
16+ import time
1517from time import sleep
1618from threading import Thread as thr
1719from functools import wraps
2729from pytgpt .utils import default_path
2830from pytgpt .utils import AwesomePrompts
2931from WebChatGPT .console import chat as webchatgpt
32+ from colorama import Fore
33+ from colorama import init as init_colorama
34+
35+ init_colorama (autoreset = True )
3036
3137getExc = lambda e : e .args [1 ] if len (e .args ) > 1 else str (e )
3238
@@ -207,7 +213,6 @@ def main(*args, **kwargs):
207213
208214class Main (cmd .Cmd ):
209215 intro = f"Welcome to AI Chat in terminal. Type 'help' or 'h' for usage info \n Submit any bug at { pytgpt .__repo__ } /issues/new"
210- prompt = f"╭─[{ getpass .getuser ().capitalize ()} @TGPT](v{ pytgpt .__version__ } )\n ╰─>"
211216
212217 def __init__ (
213218 self ,
@@ -360,6 +365,33 @@ def __init__(
360365 self .quiet = quiet
361366 self .vertical_overflow = "ellipsis"
362367 self .disable_stream = False
368+ self .provider = provider
369+ self .disable_coloring = False
370+ self .__init_time = time .time ()
371+ self .__start_time = time .time ()
372+ self .__end_time = time .time ()
373+
374+ @property
375+ def prompt (self ):
376+ current_time = datetime .datetime .now ().strftime ("%H:%M:%S" )
377+ find_range = lambda start , end : round (end - start , 1 )
378+
379+ if not self .disable_coloring :
380+ return (
381+ f"{ Fore .LIGHTGREEN_EX } ╭─[{ Fore .CYAN } { getpass .getuser ().capitalize ()} @pyTGPT]{ Fore .MAGENTA } ({ self .provider } )"
382+ f"{ Fore .BLUE } ~[{ current_time } -"
383+ f"{ Fore .RED } T'{ find_range (self .__init_time , time .time ())} s,"
384+ f"{ Fore .YELLOW } L'{ find_range (self .__start_time , self .__end_time )} s]"
385+ f"\n ╰─>{ Fore .RESET } "
386+ )
387+ else :
388+ return (
389+ f"╭─[{ getpass .getuser ().capitalize ()} @pyTGPT]({ self .provider } )"
390+ f"~[{ current_time } -"
391+ f"T'{ find_range (self .__init_time , time .time ())} s,"
392+ f"L'{ find_range (self .__start_time , self .__end_time )} s]"
393+ "\n ╰─>"
394+ )
363395
364396 def output_bond (
365397 self ,
@@ -625,6 +657,7 @@ def default(self, line, exit_on_error: bool = False):
625657 if line .startswith ("./" ):
626658 os .system (line [2 :])
627659 else :
660+ self .__start_time = time .time ()
628661 try :
629662
630663 def generate_response ():
@@ -677,6 +710,8 @@ def for_non_stream():
677710 logging .error (getExc (e ))
678711 if exit_on_error :
679712 sys .exit (1 )
713+ finally :
714+ self .__end_time = time .time ()
680715
681716 def do_sys (self , line ):
682717 """Execute system commands
@@ -854,6 +889,9 @@ def tgpt2_():
854889 is_flag = True ,
855890 help = "Postfix prompt with last copied text" ,
856891)
892+ @click .option (
893+ "-nc" , "--no-coloring" , is_flag = True , help = "Disable intro prompt font-coloring"
894+ )
857895@click .help_option ("-h" , "--help" )
858896def interactive (
859897 model ,
@@ -881,6 +919,7 @@ def interactive(
881919 quiet ,
882920 new ,
883921 with_copied ,
922+ no_coloring ,
884923):
885924 """Chat with AI interactively"""
886925 clear_history_file (filepath , new )
@@ -905,6 +944,7 @@ def interactive(
905944 busy_bar .spin_index = busy_bar_index
906945 bot .code_theme = code_theme
907946 bot .color = font_color
947+ bot .disable_coloring = no_coloring
908948 bot .prettify = prettify
909949 bot .vertical_overflow = vertical_overflow
910950 bot .disable_stream = whole
0 commit comments