ombhojane commited on
Commit
4171ee0
1 Parent(s): a52ff2f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ import google.generativeai as genai
4
+
5
+ # Configure the Gemini API key
6
+ genai.configure(api_key=st.secrets["GEMINI_API_KEY"])
7
+
8
+ # Create the model configuration
9
+ generation_config = {
10
+ "temperature": 1,
11
+ "top_p": 0.95,
12
+ "top_k": 40,
13
+ "max_output_tokens": 8192,
14
+ "response_mime_type": "text/plain",
15
+ }
16
+
17
+ model = genai.GenerativeModel(
18
+ model_name="gemini-1.5-pro",
19
+ generation_config=generation_config,
20
+ )
21
+
22
+ # Streamlit UI setup
23
+ st.title("Mental Health Conversation Analyzer")
24
+ st.write("Please enter the conversation between the patient and the doctor below:")
25
+
26
+ # Text area for user input
27
+ conversation_input = st.text_area("Conversation Input", height=300)
28
+
29
+ # Button to analyze the conversation
30
+ if st.button("Analyze Conversation"):
31
+ if conversation_input:
32
+ # Prepare the chat session with the user input
33
+ chat_session = model.start_chat(
34
+ history=[
35
+ {
36
+ "role": "user",
37
+ "parts": [
38
+ "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." +
39
+ conversation_input +
40
+ """
41
+ Identify Symptoms:
42
+ Based on the conversation, identify and list symptoms associated with ADHD and bipolar disorder.
43
+
44
+ Perform Diagnostic Tests:
45
+ 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.
46
+
47
+ Compare Results:
48
+ Compare the results of the ADHD and bipolar disorder assessments. Which disorder has more symptoms present based on the conversation?
49
+
50
+ Determine Diagnosis:
51
+ Based on the comparison, determine which disorder the user is more likely to have. Provide a rationale for your conclusion.
52
+
53
+ Conclusion and Recommendations:
54
+ Conclude with a summary of the findings and suggest next steps for the user.
55
+ """,
56
+ ],
57
+ }
58
+ ]
59
+ )
60
+
61
+ # Send the message to the model
62
+ response = chat_session.send_message("Analyze the conversation and provide insights.")
63
+
64
+ # Display the response from the model
65
+ st.subheader("Analysis Results:")
66
+ st.write(response.text)
67
+ else:
68
+ st.warning("Please enter a conversation before analyzing.")