Ais commited on
Commit
c5cd891
·
verified ·
1 Parent(s): 379615b

Update app/main.py

Browse files
Files changed (1) hide show
  1. 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 = "You are a helpful coding assistant. Give direct, clear answers with code examples when needed. Be concise and practical."
52
  else:
53
- system_prompt = "You are a teacher helping a student learn programming. Don't give direct answers. Instead, ask guiding questions to help them think and discover the solution themselves. Guide them step by step with questions like 'What do you think...?' or 'How would you...?'"
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"📝 Prompt length: {len(prompt)}")
 
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
- # Fallback responses
116
  if is_force_mode:
117
- return "I need more specific information to provide a direct answer. Please clarify your question."
118
  else:
119
- return "That's an interesting question! What do you think the answer might be? Try to break it down step by step."
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