Ais
commited on
Update app/main.py
Browse files- app/main.py +7 -6
app/main.py
CHANGED
@@ -48,9 +48,9 @@ def create_conversation_prompt(messages: list, is_force_mode: bool) -> str:
|
|
48 |
Create a simple conversation prompt with appropriate system instruction
|
49 |
"""
|
50 |
if is_force_mode:
|
51 |
-
system_prompt = "
|
52 |
else:
|
53 |
-
system_prompt = "You are a teacher
|
54 |
|
55 |
# Build conversation
|
56 |
conversation = f"System: {system_prompt}\n\n"
|
@@ -78,7 +78,8 @@ def generate_response(messages: list, is_force_mode: bool = False, max_tokens: i
|
|
78 |
prompt = create_conversation_prompt(messages, is_force_mode)
|
79 |
|
80 |
print(f"🎯 Generating {'FORCE' if is_force_mode else 'MENTOR'} response")
|
81 |
-
print(f"
|
|
|
82 |
|
83 |
# Tokenize input
|
84 |
inputs = tokenizer(prompt, return_tensors="pt", max_length=1024, truncation=True)
|
@@ -112,11 +113,11 @@ def generate_response(messages: list, is_force_mode: bool = False, max_tokens: i
|
|
112 |
print(f"✅ Generated response length: {len(response)}")
|
113 |
|
114 |
if not response or len(response) < 10:
|
115 |
-
#
|
116 |
if is_force_mode:
|
117 |
-
return "I need more specific
|
118 |
else:
|
119 |
-
return "
|
120 |
|
121 |
return response
|
122 |
|
|
|
48 |
Create a simple conversation prompt with appropriate system instruction
|
49 |
"""
|
50 |
if is_force_mode:
|
51 |
+
system_prompt = "DIRECT ANSWER MODE: Give immediate, complete solutions. Provide working code and clear explanations. Don't ask questions - just solve the problem directly."
|
52 |
else:
|
53 |
+
system_prompt = "TEACHER MODE: You are a teacher. NEVER give direct answers or solutions. ALWAYS respond with guiding questions. Ask things like 'What do you think this does?' or 'How would you approach this?' Help them discover answers themselves through questions."
|
54 |
|
55 |
# Build conversation
|
56 |
conversation = f"System: {system_prompt}\n\n"
|
|
|
78 |
prompt = create_conversation_prompt(messages, is_force_mode)
|
79 |
|
80 |
print(f"🎯 Generating {'FORCE' if is_force_mode else 'MENTOR'} response")
|
81 |
+
print(f"🔍 DEBUG: force_mode = {is_force_mode}")
|
82 |
+
print(f"📝 System prompt: {prompt.split('Student:')[0][:100]}...")
|
83 |
|
84 |
# Tokenize input
|
85 |
inputs = tokenizer(prompt, return_tensors="pt", max_length=1024, truncation=True)
|
|
|
113 |
print(f"✅ Generated response length: {len(response)}")
|
114 |
|
115 |
if not response or len(response) < 10:
|
116 |
+
# Stronger fallback responses
|
117 |
if is_force_mode:
|
118 |
+
return "Here's the direct answer: I need you to provide a more specific question so I can give you the exact solution you need."
|
119 |
else:
|
120 |
+
return "What do you think this code is trying to do? Can you trace through it step by step and tell me what you notice?"
|
121 |
|
122 |
return response
|
123 |
|