vsrinivas commited on
Commit
7999f91
1 Parent(s): b55e172

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ from PIL import Image
4
+
5
+ from funcs import detect_emotions, cosine_distance, generate_triggers_img, session_processor
6
+
7
+ sp = session_processor
8
+
9
+ img_paths = ['2.jpg','3.jpeg','4.jpeg','5.jpeg','6.jpeg']
10
+ img_path = random.choice(img_paths)
11
+ img_1 = Image.open(img_path)
12
+
13
+ img_path = '7.jpg'
14
+ img_2 = Image.open(img_path)
15
+
16
+ with gr.Blocks() as demo:
17
+ gr.Markdown("""# Falcon Cognitive Behavioural Therapy Assistant
18
+ - Your Personal AI Therapist. Start chatting...""")
19
+ therapy_session_conversation = gr.State([])
20
+
21
+ with gr.Row():
22
+
23
+ with gr.Column(scale=1):
24
+ image = gr.Image(type='pil', label ='Your Personal Therapy Assistant', value=img_1, interactive=False)
25
+ emotions = gr.Image(value=img_2, label='Top 5 Emotion Triggers')
26
+ summary_notes = gr.Textbox(label="Summary Notes of the Session", visible=False)
27
+
28
+ with gr.Column(scale=2):
29
+ chatbox = gr.Chatbot(label="Therapy Session Conversation",value =[[None, 'Therapist: Hello, What can I do for you?']], height=300)
30
+ user_input = gr.Textbox(placeholder="Enter your message here...", label="User")
31
+ submit_button = gr.Button("Submit")
32
+ submit_button.click(sp.get_doc_response_emotions, [user_input, chatbox], [user_input, chatbox, emotions])
33
+ user_input.submit(get_doc_response_emotions, [user_input, chatbox], [user_input, chatbox, emotions])
34
+ recommendations = gr.Textbox(label="Recommended Actions", visible = False)
35
+
36
+ def summarize_and_recommend_process():
37
+ sn, r = summarize_and_recommend()
38
+ return gr.update(visible=True, value=sn), gr.update(visible=True, value=r)
39
+
40
+ process_button = gr.Button("Generate Session Notes & Recommendations")
41
+ clear = gr.ClearButton(components=[user_input, chatbox, emotions, summary_notes, recommendations], value="Clear console")
42
+ process_button.click(sp.summarize_and_recommend_process, inputs=None, outputs=[summary_notes, recommendations])
43
+
44
+
45
+ demo.launch(debug=True, share=True)