File size: 2,319 Bytes
13783fd
ca9a876
 
 
 
 
13783fd
ca9a876
13783fd
 
ca9a876
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import gradio as gr
from agents import run_first_aider, run_introspect, run_journaling_pipeline
from journal_utils import (
    log_entry, log_chat_interaction, export_to_pdf, export_to_md,
    generate_emotion_map, get_weekly_summary, get_counselor_view
)

chat_history = []

with gr.Blocks() as demo:
    gr.Markdown("## πŸ€– MoodJournal Bot")

    with gr.Tab("πŸ—£οΈ Empathetic Chat"):
        mood = gr.Radio(["😊", "😐", "😒", "😠", "😰"], label="Your Mood")
        user_input = gr.Textbox(label="Talk to me", lines=2)
        chat_output = gr.Chatbot(label="AI Listener")
        chat_btn = gr.Button("Send")
        introspect_btn = gr.Button("πŸͺž Introspect with AI")

        def handle_chat(msg, mood):
            ai = run_first_aider(msg, mood)
            chat_history.append((msg, ai))
            log_chat_interaction(msg, ai, mood)
            return chat_history

        chat_btn.click(handle_chat, [user_input, mood], chat_output)

        def start_introspect(msg, mood):
            reply = run_introspect(msg, mood)
            chat_history.append(("Introspect", reply))
            return chat_history

        introspect_btn.click(start_introspect, [user_input, mood], chat_output)

    with gr.Tab("πŸ“” Journal"):
        mode = gr.Radio(["Adult (Personal Growth)", "Workplace (EAP-Focused)"])
        mood_j = gr.Radio(["😊", "😐", "😒", "😠", "😰"], label="Mood")
        entry = gr.Textbox(lines=6, label="Write your thoughts")
        outbox = gr.Textbox(label="AI Response")
        btn = gr.Button("Submit")

        def journal_entry_flow(mood, entry, mode):
            result = run_journaling_pipeline(mood, entry, mode)
            log_entry(result)
            return result["response"]

        btn.click(journal_entry_flow, [mood_j, entry, mode], outbox)
        gr.Button("Export to PDF").click(export_to_pdf, [entry, mood_j, mode])
        gr.Button("Export to Markdown").click(export_to_md, [entry, mood_j, mode])

    with gr.Tab("πŸ“Š Counselor View"):
        gr.Button("Generate Weekly Mood Chart").click(generate_emotion_map, outputs=gr.Image())
        gr.Button("Get Weekly Summary").click(get_weekly_summary, outputs=gr.JSON())
        gr.Button("Get Counselor Insights").click(get_counselor_view, outputs=gr.Textbox())

demo.launch(share=True)