wellnessv2 / app.py
ombhojane's picture
Create app.py
4171ee0 verified
raw
history blame
2.91 kB
import os
import streamlit as st
import google.generativeai as genai
# Configure the Gemini API key
genai.configure(api_key=st.secrets["GEMINI_API_KEY"])
# Create the model configuration
generation_config = {
"temperature": 1,
"top_p": 0.95,
"top_k": 40,
"max_output_tokens": 8192,
"response_mime_type": "text/plain",
}
model = genai.GenerativeModel(
model_name="gemini-1.5-pro",
generation_config=generation_config,
)
# Streamlit UI setup
st.title("Mental Health Conversation Analyzer")
st.write("Please enter the conversation between the patient and the doctor below:")
# Text area for user input
conversation_input = st.text_area("Conversation Input", height=300)
# Button to analyze the conversation
if st.button("Analyze Conversation"):
if conversation_input:
# Prepare the chat session with the user input
chat_session = model.start_chat(
history=[
{
"role": "user",
"parts": [
"Task Introduction: You are an AI assistant tasked with analyzing a conversation between a user and a mental health doctor. The user may have ADHD, bipolar disorder, or neither. Your goal is to assess the conversation, perform diagnostic tests for both disorders, and determine which disorder, if any, the user is likely experiencing." +
conversation_input +
"""
Identify Symptoms:
Based on the conversation, identify and list symptoms associated with ADHD and bipolar disorder.
Perform Diagnostic Tests:
Using the identified symptoms, perform a diagnostic test for ADHD and bipolar disorder. Score the symptoms based on the DSM-5 criteria for each disorder.
Compare Results:
Compare the results of the ADHD and bipolar disorder assessments. Which disorder has more symptoms present based on the conversation?
Determine Diagnosis:
Based on the comparison, determine which disorder the user is more likely to have. Provide a rationale for your conclusion.
Conclusion and Recommendations:
Conclude with a summary of the findings and suggest next steps for the user.
""",
],
}
]
)
# Send the message to the model
response = chat_session.send_message("Analyze the conversation and provide insights.")
# Display the response from the model
st.subheader("Analysis Results:")
st.write(response.text)
else:
st.warning("Please enter a conversation before analyzing.")