2828
2929from typing import Iterable
3030
31- #pytgpt
31+ # pytgpt
3232
3333from pytgpt .utils import Optimizers
3434from pytgpt .utils import default_path
@@ -344,6 +344,7 @@ def main(*args, **kwargs):
344344
345345 return decorator
346346
347+
347348class CustomCompleter (Completer ):
348349 """Suggests query based on user prompts"""
349350
@@ -371,14 +372,15 @@ def get_completions(self, document: Document, complete_event):
371372 )
372373 return completions
373374 for count , suggestion in enumerate (
374- suggest_query (word , timeout = 2 , die_silently = True ),
375- start = 1 ):
375+ suggest_query (word , timeout = 2 , die_silently = True ), start = 1
376+ ):
376377 completions .append (Completion (suggestion , start_position = - len (word )))
377378 if count >= self .suggestions_limit :
378379 break
379380 return completions
380381 return []
381382
383+
382384class Main (cmd .Cmd ):
383385 intro = (
384386 "Welcome to AI Chat in terminal. "
@@ -506,21 +508,6 @@ def __init__(
506508 act = awesome_prompt ,
507509 )
508510
509- elif provider == "opengpt" :
510- from pytgpt .opengpt import OPENGPT
511-
512- self .bot = OPENGPT (
513- is_conversation = disable_conversation ,
514- max_tokens = max_tokens ,
515- timeout = timeout ,
516- intro = intro ,
517- filepath = filepath ,
518- update_file = update_file ,
519- proxies = proxies ,
520- history_offset = history_offset ,
521- act = awesome_prompt ,
522- )
523-
524511 elif provider == "koboldai" :
525512 from pytgpt .koboldai import KOBOLDAI
526513
@@ -571,26 +558,6 @@ def __init__(
571558 act = awesome_prompt ,
572559 )
573560
574- elif provider == "yepchat" :
575- from pytgpt .yepchat import main as yepchat
576-
577- self .bot = yepchat .YEPCHAT (
578- is_conversation = disable_conversation ,
579- max_tokens = max_tokens ,
580- temperature = temperature ,
581- presence_penalty = top_p ,
582- frequency_penalty = top_k ,
583- top_p = top_p ,
584- model = getOr (model , yepchat .model ),
585- timeout = timeout ,
586- intro = intro ,
587- filepath = filepath ,
588- update_file = update_file ,
589- proxies = proxies ,
590- history_offset = history_offset ,
591- act = awesome_prompt ,
592- )
593-
594561 elif provider == "gpt4all" :
595562 assert auth , (
596563 "Path to LLM (.gguf or .bin) file is required. "
@@ -743,20 +710,35 @@ def __init__(
743710 self .path_to_last_response_audio = None
744711 if not non_interactive :
745712 self .completer_session = PromptSession (
746- "" ,
747- completer = ThreadedCompleter (
748- CustomCompleter (
749- self ,
750- suggestions_limit ,
751- [
752- "cd" , "copy_this" , "h" , "last_response" , "rawdog" ,
753- "settings" , "with_copied" ,
754- "clear" , "exec" , "help" , "load" , "reread" , "shell" ,
755- "code" , "exit" , "history" , "new_intro" , "reset" , "sys" ,
756- ],
757- )
758- ),
759- )
713+ "" ,
714+ completer = ThreadedCompleter (
715+ CustomCompleter (
716+ self ,
717+ suggestions_limit ,
718+ [
719+ "cd" ,
720+ "copy_this" ,
721+ "h" ,
722+ "last_response" ,
723+ "rawdog" ,
724+ "settings" ,
725+ "with_copied" ,
726+ "clear" ,
727+ "exec" ,
728+ "help" ,
729+ "load" ,
730+ "reread" ,
731+ "shell" ,
732+ "code" ,
733+ "exit" ,
734+ "history" ,
735+ "new_intro" ,
736+ "reset" ,
737+ "sys" ,
738+ ],
739+ )
740+ ),
741+ )
760742 self .__init_time = time .time ()
761743 self .__start_time = time .time ()
762744 self .__end_time = time .time ()
@@ -787,7 +769,7 @@ def find_range(start, end, hms: bool = False):
787769 f"~[`{ Fore .LIGHTWHITE_EX } 🕒{ Fore .BLUE } { current_time } -`"
788770 f"{ Fore .LIGHTWHITE_EX } 💻{ Fore .RED } { find_range (self .__init_time , time .time (), True )} -`"
789771 f"{ Fore .LIGHTWHITE_EX } ⚡{ Fore .YELLOW } { find_range (self .__start_time , self .__end_time )} s]`"
790- # f"\n╰─>"
772+ # f"\n╰─>"
791773 )
792774 whitelist = ["[" , "]" , "~" , "-" , "(" , ")" ]
793775 for character in whitelist :
@@ -800,8 +782,9 @@ def find_range(start, end, hms: bool = False):
800782 f"~[🕒{ current_time } "
801783 f"-💻{ find_range (self .__init_time , time .time (), True )} "
802784 f"-⚡{ find_range (self .__start_time , self .__end_time )} s]"
803- #"\n╰─>"
785+ # "\n╰─>"
804786 )
787+
805788 def cmdloop (self , intro = None ):
806789 """Repeatedly issue a prompt, accept input, parse an initial prefix
807790 off the received input, and dispatch to action methods, passing them
@@ -864,7 +847,6 @@ def cmdloop(self, intro=None):
864847 except ImportError :
865848 pass
866849
867-
868850 def output_bond (
869851 self ,
870852 title : str ,
@@ -1470,7 +1452,7 @@ class ChatInteractive:
14701452 ),
14711453 )
14721454 @click .option (
1473- ' -sl' ,
1455+ " -sl" ,
14741456 "--suggestions-limit" ,
14751457 type = click .INT ,
14761458 help = "Prompt suggestions limit - 0 to disable suggestion" ,
@@ -1625,7 +1607,7 @@ def interactive(
16251607 internal_exec = internal_exec ,
16261608 confirm_script = confirm_script ,
16271609 interpreter = interpreter ,
1628- suggestions_limit = suggestions_limit
1610+ suggestions_limit = suggestions_limit ,
16291611 )
16301612 busy_bar .spin_index = busy_bar_index
16311613 bot .code_theme = code_theme
@@ -1925,7 +1907,7 @@ def generate(
19251907 internal_exec = internal_exec ,
19261908 confirm_script = confirm_script ,
19271909 interpreter = interpreter ,
1928- non_interactive = True
1910+ non_interactive = True ,
19291911 )
19301912 prompt = prompt if prompt else ""
19311913 copied_placeholder = "{{copied}}"
0 commit comments