Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,95 +1,64 @@
|
|
1 |
import streamlit as st
|
2 |
-
import os
|
3 |
-
from langchain_community.chat_models import ChatHuggingFace
|
4 |
-
from langchain_community.llms import HuggingFaceEndpoint
|
5 |
-
from langchain_core.messages import HumanMessage, SystemMessage, AIMessage
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
if not hf_token:
|
10 |
-
st.error("β Hugging Face token not found. Please set the 'Data_science' environment variable.")
|
11 |
-
st.stop()
|
12 |
|
13 |
-
|
14 |
-
os.environ["HF_TOKEN"] = hf_token
|
15 |
-
|
16 |
-
# --- Load Hugging Face model (Qwen) ---
|
17 |
-
model = HuggingFaceEndpoint(
|
18 |
-
repo_id="Qwen/Qwen3-32B",
|
19 |
-
provider="nebius",
|
20 |
-
temperature=0.6,
|
21 |
-
max_new_tokens=500,
|
22 |
-
task="text-generation"
|
23 |
-
)
|
24 |
-
|
25 |
-
chat_model = ChatHuggingFace(llm=model)
|
26 |
-
|
27 |
-
# --- Streamlit styles ---
|
28 |
st.markdown("""
|
29 |
-
<style>
|
30 |
-
.
|
31 |
-
|
32 |
-
|
33 |
}
|
34 |
-
.
|
35 |
-
background-color: #
|
|
|
|
|
36 |
border-radius: 10px;
|
37 |
-
padding: 20px;
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
-
|
|
|
|
|
|
|
42 |
""", unsafe_allow_html=True)
|
43 |
|
44 |
-
#
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
st.session_state.selected_subject = "Python"
|
50 |
-
|
51 |
-
# --- UI Header ---
|
52 |
-
st.title("π Data Science Mentor")
|
53 |
-
st.markdown("Ask subject-specific questions and get guidance based on your experience level.")
|
54 |
-
|
55 |
-
# --- Experience level ---
|
56 |
-
experience = st.selectbox("π€ Select your experience level:", ["Beginner", "Intermediate", "Expert"])
|
57 |
-
|
58 |
-
# --- Subject buttons ---
|
59 |
-
st.markdown("### π Choose a Subject:")
|
60 |
-
cols = st.columns(4)
|
61 |
-
subjects = ["Python", "SQL", "Power BI", "Statistics", "Machine Learning", "Deep Learning", "Generative AI"]
|
62 |
-
for i, subject in enumerate(subjects):
|
63 |
-
if cols[i % 4].button(subject):
|
64 |
-
st.session_state.selected_subject = subject
|
65 |
-
st.session_state.message_history = [] # Reset chat on subject change
|
66 |
-
|
67 |
-
# --- Set system message based on subject & experience ---
|
68 |
-
if not st.session_state.message_history:
|
69 |
-
system_prompt = f"""
|
70 |
-
You are a highly knowledgeable data science mentor specialized in {st.session_state.selected_subject}.
|
71 |
-
Your job is to guide a {experience.lower()} learner with clear, concise, and actionable advice.
|
72 |
-
Explain concepts, best practices, and answer questions with patience and professionalism.
|
73 |
-
If relevant, include example code, use-cases, or tips.
|
74 |
-
"""
|
75 |
-
st.session_state.message_history.append(SystemMessage(content=system_prompt.strip()))
|
76 |
|
77 |
-
#
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
st.warning("β οΈ Please enter a question before submitting.")
|
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
# Set page config
|
4 |
+
st.set_page_config(page_title="Innomatics Online Trainer Bot", layout="centered")
|
|
|
|
|
|
|
5 |
|
6 |
+
# Inject custom CSS for background and buttons
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
st.markdown("""
|
8 |
+
<style>
|
9 |
+
.main {
|
10 |
+
background-color: #8B0000;
|
11 |
+
padding: 20px;
|
12 |
}
|
13 |
+
.stButton>button {
|
14 |
+
background-color: #B76F27;
|
15 |
+
color: #8B0000;
|
16 |
+
border: 2px solid #8B0000;
|
17 |
border-radius: 10px;
|
18 |
+
padding: 10px 20px;
|
19 |
+
font-size: 18px;
|
20 |
+
font-weight: bold;
|
21 |
+
width: 100%;
|
22 |
+
transition: 0.3s ease-in-out;
|
23 |
+
}
|
24 |
+
.stButton>button:hover {
|
25 |
+
background-color: #8B0000;
|
26 |
+
color: #ffffff;
|
27 |
+
border: 2px solid white;
|
28 |
}
|
29 |
+
h1, h3, p {
|
30 |
+
color: white;
|
31 |
+
}
|
32 |
+
</style>
|
33 |
""", unsafe_allow_html=True)
|
34 |
|
35 |
+
# Title and intro
|
36 |
+
st.title("Innomatics Online Trainer Bot")
|
37 |
+
st.markdown("### π Welcome to the Innomatics Online Trainer Bot!")
|
38 |
+
st.markdown("This dashboard will guide you through your doubts in various modules.")
|
39 |
+
st.markdown("## In which module do you have doubt?")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
# Button layout - 2 per row
|
42 |
+
col1, col2 = st.columns(2)
|
43 |
+
with col1:
|
44 |
+
if st.button("Python"):
|
45 |
+
st.switch_page("pages/python.py")
|
46 |
+
with col2:
|
47 |
+
if st.button("Machine Learning"):
|
48 |
+
st.switch_page("pages/machine_learning.py")
|
49 |
|
50 |
+
col3, col4 = st.columns(2)
|
51 |
+
with col3:
|
52 |
+
if st.button("Deep Learning"):
|
53 |
+
st.switch_page("pages/deep_learning.py")
|
54 |
+
with col4:
|
55 |
+
if st.button("Statistics"):
|
56 |
+
st.switch_page("pages/statistics.py")
|
57 |
|
58 |
+
col5, col6 = st.columns(2)
|
59 |
+
with col5:
|
60 |
+
if st.button("Excel"):
|
61 |
+
st.switch_page("pages/excel.py")
|
62 |
+
with col6:
|
63 |
+
if st.button("SQL"):
|
64 |
+
st.switch_page("pages/sql.py")
|
|