Update __init__.py

Added a "Response Time" feature which tells the user the amount of time elapsed during text generation in milliseconds
This commit is contained in:
Flameguy677 2023-08-07 21:09:30 +05:30 committed by GitHub
parent 6b650343b5
commit 9a7f3278ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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):
@ -178,6 +179,7 @@ Participating personalities:
ump = self.config.discussion_prompt_separator +self.config.user_name+": " if self.config.use_user_name_in_discussions else self.personality.user_message_prefix ump = self.config.discussion_prompt_separator +self.config.user_name+": " if self.config.use_user_name_in_discussions else self.personality.user_message_prefix
if self.config.use_user_name_in_discussions: if self.config.use_user_name_in_discussions:
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}")
t0 = time.time() #Time at start of request
else: else:
prompt = input(f"{ASCIIColors.color_green}You: {ASCIIColors.color_reset}") prompt = input(f"{ASCIIColors.color_green}You: {ASCIIColors.color_reset}")
if prompt == "exit": if prompt == "exit":
@ -271,6 +273,8 @@ Participating personalities:
self.log(full_discussion) self.log(full_discussion)
t1 = time.time() # Time at end of defense
print(f"{ASCIIColors.color_cyan}Response Time: {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