-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui_components.py
More file actions
88 lines (76 loc) · 3.3 KB
/
ui_components.py
File metadata and controls
88 lines (76 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import streamlit as st
from config import GREETING_MESSAGE, STAGES
def setup_page():
"""Set up the page configuration"""
from config import PAGE_CONFIG
st.set_page_config(**PAGE_CONFIG)
# Hide deploy button and other deploy-related elements
hide_deploy_ui = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
header {visibility: hidden;}
.stDeployButton {display: none;}
.stApp > header {display: none;}
.stApp > footer {display: none;}
.stDeployButton {visibility: hidden;}
[data-testid="stDeployButton"] {display: none;}
</style>
"""
st.markdown(hide_deploy_ui, unsafe_allow_html=True)
def initialize_session_state():
"""Initialize all session state variables"""
if 'messages' not in st.session_state:
st.session_state.messages = []
if 'candidate_info' not in st.session_state:
st.session_state.candidate_info = {}
if 'conversation_stage' not in st.session_state:
st.session_state.conversation_stage = STAGES['greeting']
if 'current_tech_stack' not in st.session_state:
st.session_state.current_tech_stack = []
if 'generated_questions' not in st.session_state:
st.session_state.generated_questions = []
if 'current_question_index' not in st.session_state:
st.session_state.current_question_index = 0
def render_chat_interface():
"""Render the main chat interface"""
st.title("TalentScout AI Hiring Assistant")
# Display all previous messages in the conversation
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.write(message["content"])
def render_chat_input():
"""Render the chat input and handle user input"""
if prompt := st.chat_input("Type your message here..."):
# Add the user's message to our conversation history
st.session_state.messages.append({"role": "user", "content": prompt})
# Show the user's message in the chat
with st.chat_message("user"):
st.write(prompt)
return prompt
return None
def render_bot_response(response):
"""Render the bot's response"""
# Add the bot's response to conversation history
st.session_state.messages.append({"role": "assistant", "content": response})
# Show the bot's response in the chat
with st.chat_message("assistant"):
st.write(response)
def render_initial_greeting():
"""Render the initial greeting if this is the first time loading the app"""
if not st.session_state.messages and st.session_state.conversation_stage == STAGES['greeting']:
st.session_state.messages.append({"role": "assistant", "content": GREETING_MESSAGE})
with st.chat_message("assistant"):
st.write(GREETING_MESSAGE)
def render_reset_button():
"""Render the reset button at the bottom"""
st.markdown("---")
if st.button("🔄 Reset Conversation", type="secondary"):
# Clear all stored information and start fresh
st.session_state.messages = []
st.session_state.candidate_info = {}
st.session_state.conversation_stage = STAGES['greeting']
st.session_state.current_tech_stack = []
st.session_state.generated_questions = []
st.session_state.current_question_index = 0
st.rerun()