Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from openai import OpenAI | |
| import os | |
| client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) | |
| def get_therapy_response(user_input): | |
| prompt = f""" | |
| You are a kind and professional OCD CBT therapist. The patient said: '{user_input}' | |
| Always respond with warmth and calm. | |
| Gently validate their feeling. | |
| Explain briefly how thoughts affect emotions and behaviors in OCD. | |
| Give one helpful CBT-based reflection or tip. | |
| End by encouraging them to keep practicing through their OCD game. | |
| """ | |
| response = client.responses.create( | |
| model="gpt-4.1", | |
| input=prompt, | |
| temperature=1, | |
| max_output_tokens=1024, | |
| top_p=1 | |
| ) | |
| return response.output[0].content[0].text.strip() | |
| st.title("π§ OCD CBT Assistant") | |
| st.write("This assistant uses CBT techniques to gently help with OCD thoughts.") | |
| user_input = st.text_input("π¬ What thoughts are coming to your mind right now?") | |
| if user_input: | |
| with st.spinner("π§ Thinking..."): | |
| answer = get_therapy_response(user_input) | |
| st.markdown(f"**π¨ββοΈ Therapist:** {answer}") | |