ECUiVADE commited on
Commit
e31cae8
1 Parent(s): 1b1661f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -33
app.py CHANGED
@@ -198,7 +198,7 @@ def generate(prompt, history):
198
  yield output
199
 
200
 
201
- def name_interface(name,occupation,yearsofexp,ethnicity,gender,age,reset_button):
202
  global Name, Occupation,Ethnicity,Gender,Age,chat_log_name,YearsOfExp
203
  print(reset_button)
204
  Name = name
@@ -240,37 +240,32 @@ def reset_all():
240
  unique_id = generate_unique_id()
241
  return f"All Chat components have been rest. Uniqe ID for this session is, {unique_id}. Please note this down."
242
 
243
- chat_bot=gr.ChatInterface(
244
- fn=generate,
245
- chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
246
- title="""AI Chat Bot - ECU IVADE"""
247
- )
248
-
249
- name_interface = gr.Interface(
250
- fn=name_interface,
251
- inputs=[
252
- gr.Textbox(label="Unique ID", value = unique_id ,container = True, scale = 2 ,interactive = False, show_copy_button = True),
253
- gr.Textbox(label="Name", placeholder="Enter your name here..."),
254
- gr.Textbox(label="Occupation", placeholder="Enter your occupation here..."),
255
- gr.Textbox(label="Years of Experience", placeholder="Enter the years of experience"),
256
- gr.Textbox(label="Ethnicity", placeholder="Enter your Ethnicity here..."),
257
- gr.Dropdown(choices=["Male", "Female","Other","Prefer Not To Say"], label="Gender"),
258
- gr.Textbox(label="Age", placeholder="Enter your Age here..."),
259
- ],outputs="text",
260
- title="ECU-IVADE : User Information",
261
- description="Please enter your name and occupation."
262
- )
263
-
264
-
265
- with gr.Blocks() as reset_section:
266
- gr.Markdown("Press the button below to restart the chat Interface.")
267
- with gr.Row():
268
- out = gr.Textbox(label="Output")
269
- btn = gr.Button("Reset ChatBot Instance")
270
- btn.click(fn=reset_all, inputs=None, outputs=out)
271
-
272
-
273
- tabs = gr.TabbedInterface([name_interface, chat_bot,reset_section], ["User Info", "Chat Bot","Reset Chatbot"])
274
 
275
  if __name__ == "__main__":
276
- tabs.launch(debug=True,share=False,inbrowser=True)
 
198
  yield output
199
 
200
 
201
+ def submit_user_info(name,occupation,yearsofexp,ethnicity,gender,age,reset_button):
202
  global Name, Occupation,Ethnicity,Gender,Age,chat_log_name,YearsOfExp
203
  print(reset_button)
204
  Name = name
 
240
  unique_id = generate_unique_id()
241
  return f"All Chat components have been rest. Uniqe ID for this session is, {unique_id}. Please note this down."
242
 
243
+ with gr.Blocks() as app:
244
+ gr.Markdown("# ECU-IVADE: Enhanced Conversational UI for Virtual Assistance and Dialogue Engagement")
245
+ unique_id_display = gr.Textbox(value=unique_id, label="Session Unique ID", interactive=False)
246
+
247
+ with gr.Tab("User Info"):
248
+ name = gr.Textbox(label="Name")
249
+ occupation = gr.Textbox(label="Occupation")
250
+ yearsofexp = gr.Textbox(label="Years of Experience")
251
+ ethnicity = gr.Textbox(label="Ethnicity")
252
+ gender = gr.Dropdown(choices=["Male", "Female", "Other", "Prefer Not To Say"], label="Gender")
253
+ age = gr.Textbox(label="Age")
254
+ submit_info = gr.Button("Submit")
255
+ submit_info.click(submit_user_info, inputs=[name, occupation, yearsofexp, ethnicity, gender, age], outputs=None)
256
+
257
+ with gr.Tab("Chat Bot"):
258
+ chatbot = gr.Chatbot()
259
+ msg = gr.Textbox(label="Type your message")
260
+ send = gr.Button("Send")
261
+ clear = gr.Button("Clear Chat")
262
+ send.click(generate, inputs=[msg], outputs=chatbot)
263
+ clear.click(lambda: chatbot.clear(), inputs=[], outputs=chatbot)
264
+
265
+ with gr.Tab("Reset"):
266
+ reset_button = gr.Button("Reset ChatBot Instance")
267
+ reset_output = gr.Textbox(label="Reset Output", interactive=False)
268
+ reset_button.click(reset_all, inputs=[], outputs=[reset_output])
 
 
 
 
 
269
 
270
  if __name__ == "__main__":
271
+ app.launch(debug=True)