ECUiVADE commited on
Commit
114763b
1 Parent(s): deb86d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -1,7 +1,7 @@
1
  from huggingface_hub import InferenceClient
2
  import gradio as gr
3
  import json
4
- from datetime import datetime
5
  import os
6
  from google_auth_oauthlib.flow import InstalledAppFlow
7
  from googleapiclient.discovery import build
@@ -62,8 +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.timer_duration = 600
66
-
67
 
68
  # Method to create Google Drive service instance
69
  def get_drive_service(self):
@@ -141,12 +140,18 @@ class ChatbotAPP:
141
 
142
  def generate(self,prompt, history): # Method to generate a response to the user's input
143
 
 
 
 
 
 
 
144
 
145
  #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):
146
  if self.agreed:
147
 
148
  user_msg_timestamp = datetime.now().strftime("%H:%M:%S") #capture timestamp the user message is recieved.
149
-
150
  firstmsg =""
151
  if self.isFirstRun:
152
  self.context = self.initContext
@@ -249,7 +254,6 @@ class ChatbotAPP:
249
  with gr.Blocks(theme=gr.themes.Soft()) as app:
250
  gr.Markdown("# ECU-IVADE: Chat With Barry")
251
  unique_id_display = gr.Textbox(value=self.unique_id, label="Session Unique ID", interactive=False,show_copy_button = True)
252
- self.timer = gr.Timer(value=self.timer_duration, variant="countdown")
253
 
254
 
255
  with gr.Tab("Terms and Conditions"):
 
1
  from huggingface_hub import InferenceClient
2
  import gradio as gr
3
  import json
4
+ from datetime import datetime,timedelta
5
  import os
6
  from google_auth_oauthlib.flow import InstalledAppFlow
7
  from googleapiclient.discovery import build
 
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=datetime.now() #save the chat session start
 
66
 
67
  # Method to create Google Drive service instance
68
  def get_drive_service(self):
 
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
 
254
  with gr.Blocks(theme=gr.themes.Soft()) as app:
255
  gr.Markdown("# ECU-IVADE: Chat With Barry")
256
  unique_id_display = gr.Textbox(value=self.unique_id, label="Session Unique ID", interactive=False,show_copy_button = True)
 
257
 
258
 
259
  with gr.Tab("Terms and Conditions"):