DOMMETI commited on
Commit
4057ece
Β·
verified Β·
1 Parent(s): f2892eb

Update src/pages/model.py

Browse files
Files changed (1) hide show
  1. src/pages/model.py +98 -12
src/pages/model.py CHANGED
@@ -7,25 +7,109 @@ os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.getenv("key")
7
  os.environ['HF_TOKEN'] = os.getenv("key")
8
 
9
  st.set_page_config(page_title="πŸ‘¨β€πŸ« Multi-Mentor Chat", page_icon="🧠")
10
- st.title("🧠 Multi-Topic Mentor")
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- st.markdown("### Select your Mentor:")
14
- col1, col2, col3, col4, col5, col6 = st.columns(6)
15
- with col1: st.write("🟒 Python")
16
- with col2: st.write("🟠 ML")
17
- with col3: st.write("πŸ”΅ DL")
18
- with col4: st.write("🟣 Stats")
19
- with col5: st.write("🟑 Data_Anaylasis")
20
- with col6: st.write("πŸ”΄ sql and powerbi")
21
 
 
 
22
  mentor_type = st.selectbox("Choose a mentor:", ["", "python", "machine_learning", "deep_learning", "stats", "data_anaylasis", "sql and powerbi"])
 
23
 
24
  if mentor_type:
25
  st.subheader(f"🧠 {mentor_type.upper()} Mentor Chat")
 
 
26
  experience = st.slider("Your experience (in years):", 0, 20, 1)
27
- user_input = st.text_input("Ask your question:")
28
 
 
 
 
29
 
30
  output_container = st.empty()
31
 
@@ -41,7 +125,7 @@ if mentor_type:
41
  model = HuggingFaceEndpoint(repo_id="meta-llama/Llama-3.3-70B-Instruct", provider="nebius", temperature=0.5, max_new_tokens=150, task="conversational")
42
  elif mentor_type == "sql and powerbi":
43
  model = HuggingFaceEndpoint(repo_id="meta-llama/Meta-Llama-3-70B-Instruct", provider="hyperbolic", temperature=0.5, max_new_tokens=150, task="conversational")
44
-
45
  chat_model = ChatHuggingFace(
46
  llm=model,
47
  repo_id=model.repo_id,
@@ -51,7 +135,8 @@ if mentor_type:
51
  task="conversational"
52
  )
53
 
54
-
 
55
  if st.button("Ask") and user_input:
56
  prompt = ChatPromptTemplate.from_messages([
57
  SystemMessagePromptTemplate.from_template(
@@ -69,3 +154,4 @@ if mentor_type:
69
 
70
  if st.button("Clear Output"):
71
  output_container.empty()
 
 
7
  os.environ['HF_TOKEN'] = os.getenv("key")
8
 
9
  st.set_page_config(page_title="πŸ‘¨β€πŸ« Multi-Mentor Chat", page_icon="🧠")
 
10
 
11
+ # --- Custom CSS for styling ---
12
+ st.markdown("""
13
+ <style>
14
+ body {
15
+ background: linear-gradient(135deg, #1f2937, #111827);
16
+ color: #e0e7ff;
17
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
18
+ }
19
+ h1, h2, h3 {
20
+ text-align: center;
21
+ color: #00FFFF;
22
+ text-shadow: 0 0 12px #00FFFFaa;
23
+ font-weight: 700;
24
+ margin-bottom: 0.5rem;
25
+ }
26
+ .mentor-columns div {
27
+ text-align: center;
28
+ padding: 10px 0;
29
+ font-weight: 600;
30
+ font-size: 1rem;
31
+ border-radius: 8px;
32
+ user-select: none;
33
+ }
34
+ .mentor-columns .col1 { color: #00FF00; } /* Green */
35
+ .mentor-columns .col2 { color: #FFA500; } /* Orange */
36
+ .mentor-columns .col3 { color: #1E90FF; } /* Dodger Blue */
37
+ .mentor-columns .col4 { color: #8A2BE2; } /* BlueViolet */
38
+ .mentor-columns .col5 { color: #FFD700; } /* Gold */
39
+ .mentor-columns .col6 { color: #FF4500; } /* OrangeRed */
40
+ .selectbox-container {
41
+ max-width: 400px;
42
+ margin: 0 auto 15px auto;
43
+ }
44
+ .slider-container {
45
+ max-width: 400px;
46
+ margin: 15px auto 20px auto;
47
+ }
48
+ .input-container {
49
+ max-width: 700px;
50
+ margin: 10px auto 30px auto;
51
+ }
52
+ .button-row {
53
+ text-align: center;
54
+ margin-bottom: 30px;
55
+ }
56
+ button.stButton > button {
57
+ background: linear-gradient(90deg, #00FFFF, #00CCFF);
58
+ border: none;
59
+ padding: 12px 30px;
60
+ color: #111;
61
+ font-weight: 700;
62
+ border-radius: 25px;
63
+ box-shadow: 0 0 12px #00FFFFcc;
64
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
65
+ }
66
+ button.stButton > button:hover {
67
+ transform: scale(1.1);
68
+ box-shadow: 0 0 20px #00FFFFee;
69
+ }
70
+ .output-container {
71
+ max-width: 700px;
72
+ margin: 0 auto 40px auto;
73
+ background: rgba(0, 255, 255, 0.1);
74
+ padding: 20px;
75
+ border-radius: 15px;
76
+ box-shadow: 0 0 12px #00FFFF55;
77
+ white-space: pre-wrap;
78
+ font-size: 1.1rem;
79
+ line-height: 1.4;
80
+ color: #e0f7ff;
81
+ min-height: 80px;
82
+ }
83
+ </style>
84
+ """, unsafe_allow_html=True)
85
+
86
+ # --- Title and Mentor Labels ---
87
+ st.title("🧠 Multi-Topic Mentor")
88
 
89
+ st.markdown('<div class="mentor-columns" style="display:flex; justify-content: space-around; margin-bottom:15px;">'
90
+ '<div class="col1">🟒 Python</div>'
91
+ '<div class="col2">🟠 ML</div>'
92
+ '<div class="col3">πŸ”΅ DL</div>'
93
+ '<div class="col4">🟣 Stats</div>'
94
+ '<div class="col5">🟑 Data_Analysis</div>'
95
+ '<div class="col6">πŸ”΄ SQL & PowerBI</div>'
96
+ '</div>', unsafe_allow_html=True)
97
 
98
+ # --- Mentor selectbox ---
99
+ st.markdown('<div class="selectbox-container">', unsafe_allow_html=True)
100
  mentor_type = st.selectbox("Choose a mentor:", ["", "python", "machine_learning", "deep_learning", "stats", "data_anaylasis", "sql and powerbi"])
101
+ st.markdown('</div>', unsafe_allow_html=True)
102
 
103
  if mentor_type:
104
  st.subheader(f"🧠 {mentor_type.upper()} Mentor Chat")
105
+
106
+ st.markdown('<div class="slider-container">', unsafe_allow_html=True)
107
  experience = st.slider("Your experience (in years):", 0, 20, 1)
108
+ st.markdown('</div>', unsafe_allow_html=True)
109
 
110
+ st.markdown('<div class="input-container">', unsafe_allow_html=True)
111
+ user_input = st.text_input("Ask your question:")
112
+ st.markdown('</div>', unsafe_allow_html=True)
113
 
114
  output_container = st.empty()
115
 
 
125
  model = HuggingFaceEndpoint(repo_id="meta-llama/Llama-3.3-70B-Instruct", provider="nebius", temperature=0.5, max_new_tokens=150, task="conversational")
126
  elif mentor_type == "sql and powerbi":
127
  model = HuggingFaceEndpoint(repo_id="meta-llama/Meta-Llama-3-70B-Instruct", provider="hyperbolic", temperature=0.5, max_new_tokens=150, task="conversational")
128
+
129
  chat_model = ChatHuggingFace(
130
  llm=model,
131
  repo_id=model.repo_id,
 
135
  task="conversational"
136
  )
137
 
138
+ # Buttons row
139
+ st.markdown('<div class="button-row">', unsafe_allow_html=True)
140
  if st.button("Ask") and user_input:
141
  prompt = ChatPromptTemplate.from_messages([
142
  SystemMessagePromptTemplate.from_template(
 
154
 
155
  if st.button("Clear Output"):
156
  output_container.empty()
157
+ st.markdown('</div>', unsafe_allow_html=True)