Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 3 |
|
| 4 |
# Initialize the Google Generative AI with the model and API key
|
|
@@ -63,6 +64,46 @@ def get_resources(role):
|
|
| 63 |
}
|
| 64 |
return resources.get(role, [])
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
# Initialize session state
|
| 67 |
if 'questions' not in st.session_state:
|
| 68 |
st.session_state['questions'] = []
|
|
@@ -127,6 +168,8 @@ if st.session_state['questions']:
|
|
| 127 |
with st.spinner("Generating feedback..."):
|
| 128 |
feedback = generate_feedback(st.session_state['responses'])
|
| 129 |
st.session_state['feedback'] = feedback
|
|
|
|
|
|
|
| 130 |
st.session_state['questions'] = [] # Clear questions to prevent re-displaying
|
| 131 |
st.session_state['responses'] = [] # Clear responses
|
| 132 |
st.session_state['current_question'] = 0
|
|
@@ -150,3 +193,6 @@ if st.session_state['interview_complete']:
|
|
| 150 |
st.write(f"**{resource['type']}**: [{resource['title']}]({resource['link']})")
|
| 151 |
else:
|
| 152 |
st.write("No resources available for this role.")
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from datetime import datetime
|
| 3 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 4 |
|
| 5 |
# Initialize the Google Generative AI with the model and API key
|
|
|
|
| 64 |
}
|
| 65 |
return resources.get(role, [])
|
| 66 |
|
| 67 |
+
def save_performance(role, topic, difficulty, feedback):
|
| 68 |
+
if 'performance_history' not in st.session_state:
|
| 69 |
+
st.session_state['performance_history'] = []
|
| 70 |
+
|
| 71 |
+
performance_entry = {
|
| 72 |
+
"date": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
| 73 |
+
"role": role,
|
| 74 |
+
"topic": topic,
|
| 75 |
+
"difficulty": difficulty,
|
| 76 |
+
"feedback": feedback
|
| 77 |
+
}
|
| 78 |
+
st.session_state['performance_history'].append(performance_entry)
|
| 79 |
+
|
| 80 |
+
def analyze_performance():
|
| 81 |
+
if 'performance_history' not in st.session_state or not st.session_state['performance_history']:
|
| 82 |
+
st.write("No performance data available.")
|
| 83 |
+
return
|
| 84 |
+
|
| 85 |
+
history = st.session_state['performance_history']
|
| 86 |
+
st.write("### Performance Summary")
|
| 87 |
+
|
| 88 |
+
for entry in history:
|
| 89 |
+
st.write(f"**Date:** {entry['date']}")
|
| 90 |
+
st.write(f"**Role:** {entry['role']}, **Topic:** {entry['topic']}, **Difficulty:** {entry['difficulty']}")
|
| 91 |
+
st.write(f"**Feedback:** {entry['feedback']}")
|
| 92 |
+
st.write("---")
|
| 93 |
+
|
| 94 |
+
# Analyze improvement/deterioration
|
| 95 |
+
# This is a simple textual analysis, for more complex analysis you might need to analyze feedback content in-depth
|
| 96 |
+
improvement_count = sum(1 for entry in history if "improve" in entry['feedback'].lower())
|
| 97 |
+
deterioration_count = sum(1 for entry in history if "decline" in entry['feedback'].lower())
|
| 98 |
+
|
| 99 |
+
if improvement_count > deterioration_count:
|
| 100 |
+
st.success("Overall performance is improving!")
|
| 101 |
+
elif deterioration_count > improvement_count:
|
| 102 |
+
st.warning("Performance is deteriorating.")
|
| 103 |
+
else:
|
| 104 |
+
st.info("Performance is stable.")
|
| 105 |
+
|
| 106 |
+
|
| 107 |
# Initialize session state
|
| 108 |
if 'questions' not in st.session_state:
|
| 109 |
st.session_state['questions'] = []
|
|
|
|
| 168 |
with st.spinner("Generating feedback..."):
|
| 169 |
feedback = generate_feedback(st.session_state['responses'])
|
| 170 |
st.session_state['feedback'] = feedback
|
| 171 |
+
|
| 172 |
+
save_performance(role, topic, difficulty, feedback)
|
| 173 |
st.session_state['questions'] = [] # Clear questions to prevent re-displaying
|
| 174 |
st.session_state['responses'] = [] # Clear responses
|
| 175 |
st.session_state['current_question'] = 0
|
|
|
|
| 193 |
st.write(f"**{resource['type']}**: [{resource['title']}]({resource['link']})")
|
| 194 |
else:
|
| 195 |
st.write("No resources available for this role.")
|
| 196 |
+
|
| 197 |
+
st.header("Performance Analysis")
|
| 198 |
+
analyze_performance()
|