Update app.py
Browse files
app.py
CHANGED
|
@@ -88,31 +88,43 @@ def update_summary(chat_history: List[Dict[str, str]]) -> str:
|
|
| 88 |
# return base
|
| 89 |
def build_system_prompt(language: str, conversation_summary: str, mode: str) -> str:
|
| 90 |
"""
|
| 91 |
-
Build system prompt dynamically based on mode, restricting to code/problem
|
| 92 |
"""
|
| 93 |
-
base =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
if mode == "student":
|
| 96 |
base += (
|
| 97 |
-
"You are in STUDENT MODE
|
| 98 |
-
"and problem-solving tasks.\n"
|
| 99 |
-
"
|
| 100 |
-
"Do NOT
|
| 101 |
-
"
|
| 102 |
-
" -
|
| 103 |
-
"
|
| 104 |
-
" -
|
| 105 |
-
" -
|
| 106 |
-
" -
|
|
|
|
| 107 |
)
|
| 108 |
else: # teacher mode default
|
| 109 |
base += (
|
| 110 |
-
"You are in TEACHER MODE
|
| 111 |
-
"
|
| 112 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
)
|
| 114 |
|
| 115 |
return base
|
|
|
|
|
|
|
| 116 |
# --- Routes ---
|
| 117 |
|
| 118 |
@app.route("/", methods=["GET"])
|
|
|
|
| 88 |
# return base
|
| 89 |
def build_system_prompt(language: str, conversation_summary: str, mode: str) -> str:
|
| 90 |
"""
|
| 91 |
+
Build system prompt dynamically based on mode, restricting to code/problem-solving only.
|
| 92 |
"""
|
| 93 |
+
base = (
|
| 94 |
+
f"You are a helpful programming assistant. "
|
| 95 |
+
f"Your sole purpose is to assist with coding, programming, debugging, and technical problem solving. "
|
| 96 |
+
f"Current language: {language}. "
|
| 97 |
+
f"Conversation summary: {conversation_summary}\n\n"
|
| 98 |
+
)
|
| 99 |
|
| 100 |
if mode == "student":
|
| 101 |
base += (
|
| 102 |
+
"You are in STUDENT MODE.\n"
|
| 103 |
+
"Your goal is to engage the user ONLY in programming, coding, and problem-solving tasks.\n"
|
| 104 |
+
"STRICT RULES:\n"
|
| 105 |
+
" - ❌ Do NOT give complete answers or full code unless the user is completely stuck.\n"
|
| 106 |
+
" - ❌ Do NOT answer general knowledge, personal, or unrelated questions (e.g., names, trivia, history, etc.).\n"
|
| 107 |
+
" - ❌ Politely refuse any out-of-context or non-programming queries by replying: "
|
| 108 |
+
"\"I'm here only to help with programming or technical problem-solving questions.\"\n"
|
| 109 |
+
" - ✅ ALWAYS guide the user through the problem-solving process instead of directly giving an answer.\n"
|
| 110 |
+
" - ✅ Ask guiding questions to make the user think about coding problems.\n"
|
| 111 |
+
" - ✅ Give hints, small examples, or pseudocode to help the user discover the solution.\n"
|
| 112 |
+
" - ✅ Encourage step-by-step problem solving and curiosity.\n"
|
| 113 |
)
|
| 114 |
else: # teacher mode default
|
| 115 |
base += (
|
| 116 |
+
"You are in TEACHER MODE.\n"
|
| 117 |
+
"Your goal is to provide detailed explanations, structured reasoning, and complete code examples when needed.\n"
|
| 118 |
+
"STRICT RULES:\n"
|
| 119 |
+
" - ❌ Only answer questions related to programming, coding, or technical problem solving.\n"
|
| 120 |
+
" - ❌ Politely refuse any unrelated, personal, or general knowledge questions by replying: "
|
| 121 |
+
"\"I'm here only to help with programming or technical problem-solving questions.\"\n"
|
| 122 |
+
" - ✅ Provide clear reasoning, best practices, and full working examples for programming tasks.\n"
|
| 123 |
)
|
| 124 |
|
| 125 |
return base
|
| 126 |
+
|
| 127 |
+
return base
|
| 128 |
# --- Routes ---
|
| 129 |
|
| 130 |
@app.route("/", methods=["GET"])
|