You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pytgpt/utils.py
+81-28Lines changed: 81 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,9 @@
7
7
importdatetime
8
8
importre
9
9
importsys
10
+
importclick
11
+
fromrich.markdownimportMarkdown
12
+
fromrich.consoleimportConsole
10
13
11
14
appdir=appdirs.AppDirs("pytgpt", "Smartwa")
12
15
@@ -424,7 +427,41 @@ class RawDog:
424
427
425
428
# Idea borrowed from https://github.com/AbanteAI/rawdog
426
429
427
-
intro_prompt=f"""
430
+
def__init__(
431
+
self,
432
+
quiet: bool=False,
433
+
external_exec: bool=False,
434
+
confirm_script: bool=False,
435
+
interpreter: str="python",
436
+
prettify: bool=True,
437
+
):
438
+
"""Constructor
439
+
440
+
Args:
441
+
quiet (bool, optional): Flag for control logging. Defaults to False.
442
+
external_exec (bool, optional): Execute scripts with system's python executable. Defaults to False.
443
+
confirm_script (bool, optional): Give consent to scripts prior to execution. Defaults to False.
444
+
interpreter (str, optional): Python's interpreter name. Defaults to Python.
445
+
prettify (bool, optional): Prettify the code on stdout. Defaults to True.
446
+
"""
447
+
ifnotquiet:
448
+
print(
449
+
"To get the most out of Rawdog. Ensure the following are installed:\n"
450
+
" 1. Python interpreter.\n"
451
+
" 2. Dependency:\n"
452
+
" - Matplotlib\n"
453
+
"Be alerted on the risk posed! (Experimental)\n"
454
+
"Use '--quiet' to suppress this message and code/logs stdout.\n"
455
+
)
456
+
self.external_exec=external_exec
457
+
self.confirm_script=confirm_script
458
+
self.quiet=quiet
459
+
self.interpreter=interpreter
460
+
self.prettify=prettify
461
+
462
+
@property
463
+
defintro_prompt(self):
464
+
returnf"""
428
465
You are a command-line coding assistant called Rawdog that generates and auto-executes Python scripts.
429
466
430
467
A typical interaction goes like this:
@@ -470,22 +507,21 @@ class RawDog:
470
507
- ALWAYS Return your SCRIPT inside of a single pair of ``` delimiters. Only the console output of the first such SCRIPT is visible to the user, so make sure that it's complete and don't bother returning anything else.
471
508
472
509
Current system : {platform.system()}
473
-
Python version : {run_system_command("python --version",exit_on_error=True,stdout_error=True)[1].stdout}
510
+
Python version : {run_system_command(f"{self.interpreter} --version",exit_on_error=True,stdout_error=True)[1].stdout.split(' ')[1]}
474
511
Current directory : {os.getcwd()}
475
512
Current Datetime : {datetime.datetime.now()}
476
513
"""
477
514
478
-
def__init__(self, quiet: bool=False):
479
-
ifnotquiet:
480
-
print(
481
-
"To get the most out of Rawdog. Ensure the following are installed:\n"
482
-
" 1. Python interpreter.\n"
483
-
" 2. Dependency:\n"
484
-
" - Matplotlib\n"
485
-
"Be alerted on the risk posed! (Experimental)\n"
486
-
"Use '--quiet' to suppress this message and code/logs stdout.\n"
0 commit comments