ECUiVADE commited on
Commit
a711dda
1 Parent(s): 38c204d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -17
app.py CHANGED
@@ -62,6 +62,8 @@ YearsOfExp = ""
62
  chat_log_name =""
63
  status = ""
64
 
 
 
65
  from llama_cpp import Llama
66
  llm = Llama(model_path=model_file, model_type="mistral",n_gpu_layers=-1,n_ctx = 2048)
67
 
@@ -116,12 +118,13 @@ def upload_to_google_drive():
116
  print(existing_files)
117
 
118
  data = {
119
- "name": Name,
120
- "occupation": Occupation,
121
- "years of experience": YearsOfExp,
122
- "ethnicity": Ethnicity,
123
- "gender": Gender,
124
- "age": Age,
 
125
  "chat_history": chat_log_history
126
  }
127
 
@@ -150,7 +153,8 @@ def generate(prompt, history):
150
 
151
  global isFirstRun,initContext,Name,Occupation,Ethnicity,Gender,Age,context,YearsOfExp
152
 
153
- 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):
 
154
  firstmsg =""
155
  if isFirstRun:
156
  context = initContext
@@ -210,10 +214,19 @@ def submit_user_info(name,occupation,yearsofexp,ethnicity,gender,age):
210
  YearsOfExp = yearsofexp
211
 
212
  if name and occupation and ethnicity and gender and age and yearsofexp:
213
- chat_log_name = f'chat_log_for_{Name}_{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.json'
214
  return f"You can start chatting now {Name}"
215
  else:
216
  return "Enter ALL the details to start chatting"
 
 
 
 
 
 
 
 
 
217
 
218
  def reset_chat_interface():
219
  global chat_history, chat_log_history, isFirstRun
@@ -236,7 +249,7 @@ def reset_name_interface():
236
  def reset_all():
237
  global unique_id
238
  message1 = reset_chat_interface()
239
- message2 = reset_name_interface()
240
  message3 = load_model()
241
  unique_id = generate_unique_id()
242
  return f"All Chat components have been rest. Uniqe ID for this session is, {unique_id}. Please note this down.",unique_id
@@ -246,15 +259,18 @@ with gr.Blocks() as app:
246
  unique_id_display = gr.Textbox(value=unique_id, label="Session Unique ID", interactive=False,show_copy_button = True)
247
 
248
  with gr.Tab("User Info"):
249
- name = gr.Textbox(label="Name")
250
- occupation = gr.Textbox(label="Occupation")
251
- yearsofexp = gr.Textbox(label="Years of Experience")
252
- ethnicity = gr.Textbox(label="Ethnicity")
253
- gender = gr.Dropdown(choices=["Male", "Female", "Other", "Prefer Not To Say"], label="Gender")
254
- age = gr.Textbox(label="Age")
255
- submit_info = gr.Button("Submit")
 
256
  status_textbox = gr.Textbox(label="Status", interactive = False)
257
- submit_info.click(submit_user_info, inputs=[name, occupation, yearsofexp, ethnicity, gender, age], outputs=[status_textbox])
 
 
258
 
259
  with gr.Tab("Chat Bot"):
260
  chatbot = gr.Chatbot()
 
62
  chat_log_name =""
63
  status = ""
64
 
65
+ agree_status = ""
66
+
67
  from llama_cpp import Llama
68
  llm = Llama(model_path=model_file, model_type="mistral",n_gpu_layers=-1,n_ctx = 2048)
69
 
 
118
  print(existing_files)
119
 
120
  data = {
121
+ #"name": Name,
122
+ #"occupation": Occupation,
123
+ #"years of experience": YearsOfExp,
124
+ #"ethnicity": Ethnicity,
125
+ #"gender": Gender,
126
+ #"age": Age,
127
+ "Unique ID": unique_id,
128
  "chat_history": chat_log_history
129
  }
130
 
 
153
 
154
  global isFirstRun,initContext,Name,Occupation,Ethnicity,Gender,Age,context,YearsOfExp
155
 
156
+ #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):
157
+ if agree_status:
158
  firstmsg =""
159
  if isFirstRun:
160
  context = initContext
 
214
  YearsOfExp = yearsofexp
215
 
216
  if name and occupation and ethnicity and gender and age and yearsofexp:
217
+ chat_log_name = f'chat_log_for_{unique_id}_{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.json'
218
  return f"You can start chatting now {Name}"
219
  else:
220
  return "Enter ALL the details to start chatting"
221
+
222
+ def start_chat_button(agree_to_radio):
223
+
224
+ if agree_to_radio:
225
+ agree_status = agree_to_radio
226
+ chat_log_name = f'chat_log_for_{unique_id}_{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.json'
227
+ return f"You can start chatting now"
228
+ else:
229
+ return "You must agree to the terms and conditions to proceed"
230
 
231
  def reset_chat_interface():
232
  global chat_history, chat_log_history, isFirstRun
 
249
  def reset_all():
250
  global unique_id
251
  message1 = reset_chat_interface()
252
+ #message2 = reset_name_interface()
253
  message3 = load_model()
254
  unique_id = generate_unique_id()
255
  return f"All Chat components have been rest. Uniqe ID for this session is, {unique_id}. Please note this down.",unique_id
 
259
  unique_id_display = gr.Textbox(value=unique_id, label="Session Unique ID", interactive=False,show_copy_button = True)
260
 
261
  with gr.Tab("User Info"):
262
+ #name = gr.Textbox(label="Name")
263
+ #occupation = gr.Textbox(label="Occupation")
264
+ #yearsofexp = gr.Textbox(label="Years of Experience")
265
+ #ethnicity = gr.Textbox(label="Ethnicity")
266
+ #gender = gr.Dropdown(choices=["Male", "Female", "Other", "Prefer Not To Say"], label="Gender")
267
+ #age = gr.Textbox(label="Age")
268
+ #submit_info = gr.Button("Submit")
269
+ start_chat_button = gr.Button("Start Chat with Chatlog")
270
  status_textbox = gr.Textbox(label="Status", interactive = False)
271
+ agree_to_radio = gr.Radio(["I have read and understand the terms and conditions."]),
272
+ #submit_info.click(submit_user_info, inputs=[name, occupation, yearsofexp, ethnicity, gender, age], outputs=[status_textbox])
273
+ start_chat_button.click(submit_user_info, inputs=[agree_to_radio], outputs=[status_textbox])
274
 
275
  with gr.Tab("Chat Bot"):
276
  chatbot = gr.Chatbot()