mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-19 04:37:54 +00:00
Merge pull request #3 from Flameguy677/main
Added ResponseTime to Console App
This commit is contained in:
commit
5a14f1554a
@ -11,6 +11,7 @@ from typing import Callable
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import argparse
|
import argparse
|
||||||
import yaml
|
import yaml
|
||||||
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class Conversation(LollmsApplication):
|
class Conversation(LollmsApplication):
|
||||||
@ -21,13 +22,14 @@ class Conversation(LollmsApplication):
|
|||||||
show_commands_list:bool=False,
|
show_commands_list:bool=False,
|
||||||
show_personality_infos:bool=True,
|
show_personality_infos:bool=True,
|
||||||
show_model_infos:bool=True,
|
show_model_infos:bool=True,
|
||||||
show_welcome_message:bool=True
|
show_welcome_message:bool=True,
|
||||||
|
show_time_elapsed:bool = False
|
||||||
):
|
):
|
||||||
# Fore it to be a path
|
# Fore it to be a path
|
||||||
self.configuration_path = configuration_path
|
self.configuration_path = configuration_path
|
||||||
self.is_logging = False
|
self.is_logging = False
|
||||||
self.log_file_path = ""
|
self.log_file_path = ""
|
||||||
|
self.show_time_elapsed = show_time_elapsed
|
||||||
self.bot_says = ""
|
self.bot_says = ""
|
||||||
|
|
||||||
# get paths
|
# get paths
|
||||||
@ -96,7 +98,7 @@ class Conversation(LollmsApplication):
|
|||||||
self.log_file_path = home_dir/file_name
|
self.log_file_path = home_dir/file_name
|
||||||
if self.log_file_path.exists():
|
if self.log_file_path.exists():
|
||||||
if not self.ask_override_file():
|
if not self.ask_override_file():
|
||||||
print("Canceled")
|
print("Cancelled")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
with(open(self.log_file_path, "w") as f):
|
with(open(self.log_file_path, "w") as f):
|
||||||
@ -180,6 +182,8 @@ Participating personalities:
|
|||||||
prompt = input(f"{ASCIIColors.color_green}{self.config.user_name}: {ASCIIColors.color_reset}")
|
prompt = input(f"{ASCIIColors.color_green}{self.config.user_name}: {ASCIIColors.color_reset}")
|
||||||
else:
|
else:
|
||||||
prompt = input(f"{ASCIIColors.color_green}You: {ASCIIColors.color_reset}")
|
prompt = input(f"{ASCIIColors.color_green}You: {ASCIIColors.color_reset}")
|
||||||
|
if self.show_time_elapsed:
|
||||||
|
t0 = time.time() #Time at start of request
|
||||||
if prompt == "exit":
|
if prompt == "exit":
|
||||||
return
|
return
|
||||||
if prompt == "menu":
|
if prompt == "menu":
|
||||||
@ -271,6 +275,9 @@ Participating personalities:
|
|||||||
|
|
||||||
self.log(full_discussion)
|
self.log(full_discussion)
|
||||||
|
|
||||||
|
if self.show_time_elapsed:
|
||||||
|
t1 = time.time() # Time at end of response
|
||||||
|
print(f"{ASCIIColors.color_cyan}Time Elapsed: {ASCIIColors.color_reset}",str(int((t1-t0)*1000)),"ms\n") # Total time elapsed since t0 in ms
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Keyboard interrupt detected.\nBye")
|
print("Keyboard interrupt detected.\nBye")
|
||||||
break
|
break
|
||||||
@ -290,6 +297,8 @@ def main():
|
|||||||
parser.add_argument('--reset_personal_path', action='store_true', help='Reset the personal path')
|
parser.add_argument('--reset_personal_path', action='store_true', help='Reset the personal path')
|
||||||
parser.add_argument('--reset_config', action='store_true', help='Reset the configurations')
|
parser.add_argument('--reset_config', action='store_true', help='Reset the configurations')
|
||||||
parser.add_argument('--reset_installs', action='store_true', help='Reset all installation status')
|
parser.add_argument('--reset_installs', action='store_true', help='Reset all installation status')
|
||||||
|
parser.add_argument('--show_time_elapsed', action='store_true', help='Enables response time')
|
||||||
|
|
||||||
|
|
||||||
# Parse the command-line arguments
|
# Parse the command-line arguments
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -308,14 +317,15 @@ def main():
|
|||||||
ASCIIColors.success("LOLLMS configuration reset successfully")
|
ASCIIColors.success("LOLLMS configuration reset successfully")
|
||||||
except:
|
except:
|
||||||
ASCIIColors.success("Couldn't reset LOLLMS configuration")
|
ASCIIColors.success("Couldn't reset LOLLMS configuration")
|
||||||
|
if args.show_time_elapsed:
|
||||||
|
show_time_elapsed = True
|
||||||
|
|
||||||
# Parse the command-line arguments
|
# Parse the command-line arguments
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
configuration_path = args.configuration_path
|
configuration_path = args.configuration_path
|
||||||
|
|
||||||
lollms_app = Conversation(configuration_path=configuration_path, show_commands_list=True)
|
lollms_app = Conversation(configuration_path=configuration_path, show_commands_list=True, show_time_elapsed=show_time_elapsed)
|
||||||
lollms_app.start_conversation()
|
lollms_app.start_conversation()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user