67Ayush87 commited on
Commit
631de81
·
verified ·
1 Parent(s): 56a1af5

Update pages/deep_learning.py

Browse files
Files changed (1) hide show
  1. pages/deep_learning.py +0 -103
pages/deep_learning.py CHANGED
@@ -3,62 +3,6 @@ import os
3
  from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
4
  from langchain_core.messages import HumanMessage, SystemMessage
5
 
6
- hf = os.getenv('Data_science')
7
- os.environ['HUGGINGFACEHUB_API_TOKEN'] = hf
8
- os.environ['HF_TOKEN'] = hf
9
-
10
- # Page config
11
- st.set_page_config(page_title="Python Mentor Chat", layout="centered")
12
-
13
- # Inject home page CSS style
14
- st.markdown("""
15
- <style>
16
- .main {
17
- background: linear-gradient(135deg, #430089 0%, #82ffa1 100%);
18
- padding: 2rem;
19
- font-family: 'Segoe UI', sans-serif;
20
- }
21
- .stButton>button {
22
- background: #ffffff10;
23
- border: 2px solid #ffffff50;
24
- color: white;
25
- font-size: 18px;
26
- font-weight: 600;
27
- padding: 0.8em 1.2em;
28
- border-radius: 12px;
29
- width: 100%;
30
- transition: 0.3s ease;
31
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
32
- }
33
- .stButton>button:hover {
34
- background: #ffffff30;
35
- border-color: #fff;
36
- color: #ffffff;
37
- }
38
- h1, h3, p, label {
39
- color: #ffffff;
40
- text-align: center;
41
- }
42
- hr {
43
- border: 1px solid #ffffff50;
44
- margin: 2em 0;
45
- }
46
- .css-1aumxhk {
47
- color: white;
48
- }
49
- </style>
50
- """, unsafe_allow_html=True)
51
-
52
- # Title
53
- st.title("🐍 Python Mentor Chat")
54
-
55
- # Sidebar
56
- st.sidebar.title("Mentor Preferences")
57
- experience_label = st.sidebar.selectbox(import streamlit as st
58
- import os
59
- from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
60
- from langchain_core.messages import HumanMessage, SystemMessage
61
-
62
  # Set environment variables for Hugging Face token
63
  hf = os.getenv('hf')
64
  os.environ['HUGGINGFACEHUB_API_TOKEN'] = hf
@@ -154,53 +98,6 @@ if submit and user_input:
154
 
155
  # Display chat history
156
  st.subheader("🗨️ Chat History")
157
- for user, bot in st.session_state[PAGE_KEY]:
158
- st.markdown(f"**You:** {user}")
159
- st.markdown(f"**Mentor:** {bot}")
160
- st.markdown("---")
161
-
162
- "Select your experience level:", ["Beginner", "Intermediate", "Experienced"]
163
- )
164
-
165
- # Initialize model
166
- deep_seek_skeleton = HuggingFaceEndpoint(
167
- repo_id='meta-llama/Llama-3.2-3B-Instruct',
168
- provider='sambanova',
169
- temperature=0.7,
170
- max_new_tokens=50,
171
- task='conversational'
172
- )
173
- deep_seek = ChatHuggingFace(
174
- llm=deep_seek_skeleton,
175
- repo_id='meta-llama/Llama-3.2-3B-Instruct',
176
- provider='sambanova',
177
- temperature=0.7,
178
- max_new_tokens=50,
179
- task='conversational'
180
- )
181
-
182
- PAGE_KEY = "python_chat_history"
183
- if PAGE_KEY not in st.session_state:
184
- st.session_state[PAGE_KEY] = []
185
-
186
- # Chat input form
187
- with st.form(key="chat_form"):
188
- user_input = st.text_input("Ask your question:")
189
- submit = st.form_submit_button("Send")
190
-
191
- # Chat logic
192
- if submit and user_input:
193
- system_prompt = (
194
- f"Act as a python mentor with {experience_label.lower()} experience. "
195
- f"Teach in a friendly manner and keep answers within 150 words. "
196
- f"If a question is not about python, politely mention it's out of scope."
197
- )
198
- messages = [SystemMessage(content=system_prompt), HumanMessage(content=user_input)]
199
- result = deep_seek.invoke(messages)
200
- st.session_state[PAGE_KEY].append((user_input, result.content))
201
-
202
- # Chat history
203
- st.subheader("🗨️ Chat History")
204
  for user, bot in st.session_state[PAGE_KEY]:
205
  st.markdown(f"**You:** {user}")
206
  st.markdown(f"**Mentor:** {bot}")
 
3
  from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
4
  from langchain_core.messages import HumanMessage, SystemMessage
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  # Set environment variables for Hugging Face token
7
  hf = os.getenv('hf')
8
  os.environ['HUGGINGFACEHUB_API_TOKEN'] = hf
 
98
 
99
  # Display chat history
100
  st.subheader("🗨️ Chat History")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  for user, bot in st.session_state[PAGE_KEY]:
102
  st.markdown(f"**You:** {user}")
103
  st.markdown(f"**Mentor:** {bot}")