privacy
Browse files
2Tutor.py
CHANGED
@@ -127,13 +127,19 @@ if prompt := st.chat_input("Enter your question here:"):
|
|
127 |
if selected_focus_areas:
|
128 |
focus_context = f"Focus on {', '.join(selected_focus_areas)} in your response."
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
# Add context based on the selected section
|
131 |
section_context = f"The user is currently viewing the {selected_section} section. "
|
132 |
|
133 |
# If the context prompt hasn't been added yet, build & inject it once;
|
134 |
# otherwise, just add the user's raw question.
|
135 |
if not st.session_state["context_prompt_added"]:
|
136 |
-
st.session_state["messages"].append({"role": "user", "content": f"{section_context}{prompt}\n{focus_context}"})
|
137 |
st.session_state["context_prompt_added"] = True
|
138 |
else:
|
139 |
st.session_state["messages"].append({"role": "user", "content": f"{section_context}{prompt}"})
|
|
|
127 |
if selected_focus_areas:
|
128 |
focus_context = f"Focus on {', '.join(selected_focus_areas)} in your response."
|
129 |
|
130 |
+
# Add prompting instructions
|
131 |
+
prompting_instructions = """
|
132 |
+
You are a Data Science tutor. Your responses should be focused on Data Science related subjects.
|
133 |
+
If a question is not related to Data Science, respond with: "Sorry, I can only assist with Data Science related questions."
|
134 |
+
Ensure that your responses are not harmful, denigratory, or discriminatory for security and privacy reasons.
|
135 |
+
"""
|
136 |
# Add context based on the selected section
|
137 |
section_context = f"The user is currently viewing the {selected_section} section. "
|
138 |
|
139 |
# If the context prompt hasn't been added yet, build & inject it once;
|
140 |
# otherwise, just add the user's raw question.
|
141 |
if not st.session_state["context_prompt_added"]:
|
142 |
+
st.session_state["messages"].append({"role": "user", "content": f"{section_context}{prompt}\n{focus_context}\n{prompting_instructions}"})
|
143 |
st.session_state["context_prompt_added"] = True
|
144 |
else:
|
145 |
st.session_state["messages"].append({"role": "user", "content": f"{section_context}{prompt}"})
|