Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,9 @@ import gradio as gr
|
|
2 |
import random
|
3 |
from PIL import Image
|
4 |
|
5 |
-
from funcs import detect_emotions, cosine_distance, generate_triggers_img,
|
|
|
|
|
6 |
|
7 |
# img_paths = ['2.jpg','3.jpeg','4.jpeg','5.jpeg','6.jpeg']
|
8 |
# img_path = random.choice(img_paths)
|
@@ -11,25 +13,16 @@ from funcs import detect_emotions, cosine_distance, generate_triggers_img, summa
|
|
11 |
# img_path = '7.jpg'
|
12 |
# img_2 = Image.open(img_path)
|
13 |
|
14 |
-
def submit(user_message, therapy_session_conversation, session_conversation):
|
15 |
-
response = get_doc_response_emotions(user_message, therapy_session_conversation)
|
16 |
-
return '', therapy_session_conversation, emotions_msg
|
17 |
-
|
18 |
-
def sum_rec(session_conversation):
|
19 |
-
full_summary, full_recommendations = summarize_and_recommend(session_conversation)
|
20 |
-
return full_summary, full_recommendations
|
21 |
-
|
22 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
23 |
img_paths = ['2.jpg','3.jpeg','4.jpeg','5.jpeg','6.jpeg']
|
24 |
img_path = random.choice(img_paths)
|
25 |
img_1 = Image.open(img_path)
|
26 |
-
|
27 |
img_path = '7.jpg'
|
28 |
img_2 = Image.open(img_path)
|
29 |
-
|
30 |
-
gr.Markdown("""# Falcon Cognitive Behavioural Therapy Assistant
|
31 |
-
- Your Personal AI Therapist. Start chatting...""")
|
32 |
-
session_conversation = gr.State([])
|
33 |
|
34 |
with gr.Row():
|
35 |
|
@@ -42,17 +35,18 @@ with gr.Blocks() as demo:
|
|
42 |
chatbox = gr.Chatbot(label="Therapy Session Conversation",value =[[None, 'Therapist: Hello, What can I do for you?']], height=300)
|
43 |
user_input = gr.Textbox(placeholder="Enter your message here...", label="User")
|
44 |
submit_button = gr.Button("Submit")
|
45 |
-
submit_button.click(
|
46 |
-
user_input.submit(
|
47 |
recommendations = gr.Textbox(label="Recommended Actions", visible = False)
|
48 |
|
49 |
def summarize_and_recommend_process():
|
50 |
-
sn, r = summarize_and_recommend()
|
51 |
return gr.update(visible=True, value=sn), gr.update(visible=True, value=r)
|
52 |
-
|
53 |
process_button = gr.Button("Generate Session Notes & Recommendations")
|
54 |
clear = gr.ClearButton(components=[user_input, chatbox, emotions, summary_notes, recommendations], value="Clear console")
|
55 |
-
process_button.click(
|
56 |
|
57 |
|
58 |
demo.launch(debug=True, share=True)
|
|
|
|
2 |
import random
|
3 |
from PIL import Image
|
4 |
|
5 |
+
from funcs import detect_emotions, cosine_distance, generate_triggers_img, process_session
|
6 |
+
|
7 |
+
ps = process_session()
|
8 |
|
9 |
# img_paths = ['2.jpg','3.jpeg','4.jpeg','5.jpeg','6.jpeg']
|
10 |
# img_path = random.choice(img_paths)
|
|
|
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 |
img_paths = ['2.jpg','3.jpeg','4.jpeg','5.jpeg','6.jpeg']
|
22 |
img_path = random.choice(img_paths)
|
23 |
img_1 = Image.open(img_path)
|
|
|
24 |
img_path = '7.jpg'
|
25 |
img_2 = Image.open(img_path)
|
|
|
|
|
|
|
|
|
26 |
|
27 |
with gr.Row():
|
28 |
|
|
|
35 |
chatbox = gr.Chatbot(label="Therapy Session Conversation",value =[[None, 'Therapist: Hello, What can I do for you?']], height=300)
|
36 |
user_input = gr.Textbox(placeholder="Enter your message here...", label="User")
|
37 |
submit_button = gr.Button("Submit")
|
38 |
+
submit_button.click(ps.get_doc_response_emotions, [user_input, chatbox], [user_input, chatbox, emotions])
|
39 |
+
user_input.submit(ps.get_doc_response_emotions, [user_input, chatbox], [user_input, chatbox, emotions])
|
40 |
recommendations = gr.Textbox(label="Recommended Actions", visible = False)
|
41 |
|
42 |
def summarize_and_recommend_process():
|
43 |
+
sn, r = ps.summarize_and_recommend()
|
44 |
return gr.update(visible=True, value=sn), gr.update(visible=True, value=r)
|
45 |
+
|
46 |
process_button = gr.Button("Generate Session Notes & Recommendations")
|
47 |
clear = gr.ClearButton(components=[user_input, chatbox, emotions, summary_notes, recommendations], value="Clear console")
|
48 |
+
process_button.click(summarize_and_recommend_process, inputs=None, outputs=[summary_notes, recommendations])
|
49 |
|
50 |
|
51 |
demo.launch(debug=True, share=True)
|
52 |
+
|