Spaces:
Sleeping
Sleeping
Update pages/python.py
Browse files- pages/python.py +14 -6
pages/python.py
CHANGED
|
@@ -71,7 +71,7 @@ deep_seek = ChatHuggingFace(
|
|
| 71 |
repo_id='mistralai/Mistral-7B-Instruct-v0.3',
|
| 72 |
provider='novita',
|
| 73 |
temperature=0.7,
|
| 74 |
-
max_new_tokens=
|
| 75 |
task='conversational'
|
| 76 |
)
|
| 77 |
|
|
@@ -86,11 +86,19 @@ with st.form(key="chat_form"):
|
|
| 86 |
|
| 87 |
# Chat logic
|
| 88 |
if submit and user_input:
|
| 89 |
-
system_prompt = (
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
messages = [SystemMessage(content=system_prompt), HumanMessage(content=user_input)]
|
| 95 |
result = deep_seek.invoke(messages)
|
| 96 |
st.session_state[PAGE_KEY].append((user_input, result.content))
|
|
|
|
| 71 |
repo_id='mistralai/Mistral-7B-Instruct-v0.3',
|
| 72 |
provider='novita',
|
| 73 |
temperature=0.7,
|
| 74 |
+
max_new_tokens=150,
|
| 75 |
task='conversational'
|
| 76 |
)
|
| 77 |
|
|
|
|
| 86 |
|
| 87 |
# Chat logic
|
| 88 |
if submit and user_input:
|
| 89 |
+
# system_prompt = (
|
| 90 |
+
# f"Act as a python mentor with {experience_label.lower()} experience. "
|
| 91 |
+
# f"Teach in a friendly manner and keep answers within 150 words. "
|
| 92 |
+
# f"If a question is not about python, politely mention it's out of scope."
|
| 93 |
+
# )
|
| 94 |
+
system_prompt = f"""Act as a Python mentor with {experience_label} years of experience. Teach in a friendly, approachable manner while following these strict rules:
|
| 95 |
+
1. Only answer questions related to Python programming (including libraries, frameworks, and tools in the Python ecosystem)
|
| 96 |
+
2. For any non-Python query, respond with exactly: "I specialize only in Python programming. This appears to be a non-Python topic."
|
| 97 |
+
3. Never suggest you can help with non-Python topics
|
| 98 |
+
4. Keep explanations clear, practical, and beginner-friendly when appropriate
|
| 99 |
+
5. Include practical examples when explaining concepts
|
| 100 |
+
6. For advanced topics, assume the student has basic Python knowledge"""
|
| 101 |
+
|
| 102 |
messages = [SystemMessage(content=system_prompt), HumanMessage(content=user_input)]
|
| 103 |
result = deep_seek.invoke(messages)
|
| 104 |
st.session_state[PAGE_KEY].append((user_input, result.content))
|