File size: 1,633 Bytes
633e9a7
d85d629
 
41fc4c5
633e9a7
 
41fc4c5
6c02936
633e9a7
 
 
41fc4c5
 
633e9a7
 
41fc4c5
 
633e9a7
 
 
 
 
 
 
 
41fc4c5
633e9a7
 
 
 
 
 
 
 
 
 
 
 
41fc4c5
 
633e9a7
 
 
 
 
 
 
 
41fc4c5
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
import streamlit as st
from huggingface_hub import InferenceClient

client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.1")

class GroupTherapyAgent:
    def __init__(self, client):
        self.client = client
        self.max_length = 64

    def get_response(self, user_question):
        response = self.client(text=user_question, max_length=self.max_length, num_beams=4)
        return response[0]['generated_text']

class GroupTherapyApplication:
    def __init__(self, client):
        self.agents = [GroupTherapyAgent(client) for _ in range(4)]

    def get_advice(self, user_question):
        advice = []
        for agent in self.agents:
            response = agent.get_response(user_question)
            advice.append(response)
        return advice

app = GroupTherapyApplication(client)
advice = app.get_advice("I feel anxious when I have to speak in front of a group of people.")
print(f"Advice from Agents:\n{advice}")

# Streamlit App Layout
st.title("Group Therapy Session App")

# User question input
user_question = st.text_area("Enter your question or share your experience:", height=150)

# Button to submit question
if st.button("Get Advice"):
    if user_question:
        # Call to the GroupTherapyApplication to get real responses
        responses = app.get_advice(user_question)

        for idx, response in enumerate(responses, start=1):
            st.markdown(f"**Agent {idx}:** {response}")
    else:
        st.warning("Please enter a question or experience to share.")

# Footer
st.markdown("---")
st.caption("Disclaimer: The responses are simulated and for demonstration purposes only.")