Spaces:
Sleeping
Sleeping
ogegadavis254
commited on
Commit
•
6dac4be
1
Parent(s):
bc9d32e
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
|
|
2 |
import requests
|
3 |
import os
|
4 |
from dotenv import load_dotenv
|
5 |
-
from requests.exceptions import RequestException
|
6 |
from nltk.sentiment import SentimentIntensityAnalyzer
|
7 |
import nltk
|
8 |
|
@@ -33,6 +32,10 @@ model_pre_instructions = {
|
|
33 |
# Initialize sentiment analyzer
|
34 |
sia = SentimentIntensityAnalyzer()
|
35 |
|
|
|
|
|
|
|
|
|
36 |
# Function to predict diagnosis based on sentiment analysis and chat content
|
37 |
def predict_diagnosis(messages):
|
38 |
# Perform sentiment analysis
|
@@ -80,10 +83,14 @@ if st.session_state.get('selected_model') != selected_model:
|
|
80 |
st.info(f"You have switched to {selected_model}.")
|
81 |
st.sidebar.button('Reset Chat', on_click=reset_conversation)
|
82 |
|
83 |
-
# Display diagnosis based on chat messages
|
84 |
-
|
85 |
-
st.
|
86 |
-
st.sidebar.
|
|
|
|
|
|
|
|
|
87 |
|
88 |
# Add logo and text to the sidebar
|
89 |
st.sidebar.image("https://assets.isu.pub/document-structure/221118065013-a6029cf3d563afaf9b946bb9497d45d4/v1/2841525b232adaef7bd0efe1da81a4c5.jpeg", width=200)
|
|
|
2 |
import requests
|
3 |
import os
|
4 |
from dotenv import load_dotenv
|
|
|
5 |
from nltk.sentiment import SentimentIntensityAnalyzer
|
6 |
import nltk
|
7 |
|
|
|
32 |
# Initialize sentiment analyzer
|
33 |
sia = SentimentIntensityAnalyzer()
|
34 |
|
35 |
+
# Initialize session state
|
36 |
+
if 'messages' not in st.session_state:
|
37 |
+
st.session_state.messages = []
|
38 |
+
|
39 |
# Function to predict diagnosis based on sentiment analysis and chat content
|
40 |
def predict_diagnosis(messages):
|
41 |
# Perform sentiment analysis
|
|
|
83 |
st.info(f"You have switched to {selected_model}.")
|
84 |
st.sidebar.button('Reset Chat', on_click=reset_conversation)
|
85 |
|
86 |
+
# Display diagnosis based on chat messages if messages exist
|
87 |
+
if 'messages' in st.session_state:
|
88 |
+
diagnosis = predict_diagnosis(st.session_state.messages)
|
89 |
+
st.sidebar.subheader("User Diagnosis")
|
90 |
+
st.sidebar.write(", ".join(diagnosis))
|
91 |
+
else:
|
92 |
+
st.sidebar.subheader("User Diagnosis")
|
93 |
+
st.sidebar.write("No messages yet")
|
94 |
|
95 |
# Add logo and text to the sidebar
|
96 |
st.sidebar.image("https://assets.isu.pub/document-structure/221118065013-a6029cf3d563afaf9b946bb9497d45d4/v1/2841525b232adaef7bd0efe1da81a4c5.jpeg", width=200)
|