Update app.py
Browse files
app.py
CHANGED
@@ -62,7 +62,7 @@ class ChatbotAPP:
|
|
62 |
self.service = self.get_drive_service() # Google Drive service instance
|
63 |
self.app = self.create_app() # Gradio app instance
|
64 |
self.chat_log_name = "" # Filename for the chat log
|
65 |
-
self.start_time=
|
66 |
|
67 |
# Method to create Google Drive service instance
|
68 |
def get_drive_service(self):
|
@@ -139,21 +139,28 @@ class ChatbotAPP:
|
|
139 |
print(f"Updated existing file with ID: {updated_file.get('id')}")
|
140 |
|
141 |
def generate(self,prompt, history): # Method to generate a response to the user's input
|
142 |
-
|
143 |
-
current_time = datetime.now()
|
144 |
-
|
145 |
-
if (current_time - self.start_time) > timedelta (seconds = 20):
|
146 |
-
temp_history = []
|
147 |
-
temp_history.append(("\n\n\n\n\n","10 minutes has been elapsed. Barry died due to not getting treatment!"))
|
148 |
-
return temp_history
|
149 |
|
150 |
#if not len(Name) == 0 and not len(Occupation) == 0 and not len(Ethnicity) == 0 and not len(Gender) == 0 and not len(Age) == 0 and not len(YearsOfExp):
|
151 |
if self.agreed:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
user_msg_timestamp = datetime.now().strftime("%H:%M:%S") #capture timestamp the user message is recieved.
|
154 |
|
155 |
firstmsg =""
|
156 |
if self.isFirstRun:
|
|
|
157 |
self.context = self.initContext
|
158 |
self.isFirstRun = False
|
159 |
firstmsg = prompt
|
|
|
62 |
self.service = self.get_drive_service() # Google Drive service instance
|
63 |
self.app = self.create_app() # Gradio app instance
|
64 |
self.chat_log_name = "" # Filename for the chat log
|
65 |
+
self.start_time=None #save the chat session start
|
66 |
|
67 |
# Method to create Google Drive service instance
|
68 |
def get_drive_service(self):
|
|
|
139 |
print(f"Updated existing file with ID: {updated_file.get('id')}")
|
140 |
|
141 |
def generate(self,prompt, history): # Method to generate a response to the user's input
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
#if not len(Name) == 0 and not len(Occupation) == 0 and not len(Ethnicity) == 0 and not len(Gender) == 0 and not len(Age) == 0 and not len(YearsOfExp):
|
144 |
if self.agreed:
|
145 |
+
|
146 |
+
current_time = datetime.now()
|
147 |
+
|
148 |
+
if (current_time - self.start_time) > timedelta (minutes = 2):
|
149 |
+
temp_history = []
|
150 |
+
temp_history.append(("""
|
151 |
+
.
|
152 |
+
.
|
153 |
+
.
|
154 |
+
.
|
155 |
+
.
|
156 |
+
.""","10 minutes has been elapsed. Barry died due to not getting treatment!"))
|
157 |
+
return temp_history
|
158 |
|
159 |
user_msg_timestamp = datetime.now().strftime("%H:%M:%S") #capture timestamp the user message is recieved.
|
160 |
|
161 |
firstmsg =""
|
162 |
if self.isFirstRun:
|
163 |
+
seld.start_time = datetime.now()
|
164 |
self.context = self.initContext
|
165 |
self.isFirstRun = False
|
166 |
firstmsg = prompt
|