XY26 commited on
Commit
fa636c4
·
verified ·
1 Parent(s): a33411c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -26,8 +26,8 @@ def smart_response(message, history):
26
 
27
  if is_opinion:
28
  print(f"🧠 OPINION MODE: {message}")
29
- # DUAL FRAME PROMPT (Fixed for stability)
30
- # We ensure it stops generating after the response
31
  prompt = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
32
 
33
  ### Instruction:
@@ -35,20 +35,25 @@ def smart_response(message, history):
35
 
36
  ### Response:
37
  """
38
- # Added double newline to stop early if it tries to start a new header
39
- stop_tokens = ["</s>", "###", "\n###"]
40
 
41
  else:
42
  print(f"ℹ️ CHAT MODE: {message}")
43
- # STANDARD CHAT PROMPT (Fixed)
44
- # 1. Added '<s>' (Beginning of String) - CRITICAL for Mistral
45
- # 2. Removed "Question:" label (This prevents the 'Quiz Mode' loop)
46
- # 3.Kept the structure simple so it knows it is a chat
47
- prompt = f"<s>[INST] {message} [/INST]"
48
-
49
- stop_tokens = ["</s>", "[INST]"]
 
 
 
50
 
51
  # --- GENERATION ---
 
 
 
 
52
  output = llm(
53
  prompt,
54
  max_tokens=512,
 
26
 
27
  if is_opinion:
28
  print(f"🧠 OPINION MODE: {message}")
29
+ # DUAL FRAME PROMPT
30
+ # We use the standard instruction format the model learned during fine-tuning.
31
  prompt = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
32
 
33
  ### Instruction:
 
35
 
36
  ### Response:
37
  """
 
 
38
 
39
  else:
40
  print(f"ℹ️ CHAT MODE: {message}")
41
+ # FACTUAL PROMPT
42
+ # CRITICAL FIX: We use the SAME format (Alpaca), but we add a specific
43
+ # instruction telling the model to be "concise" and "factual".
44
+ prompt = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
45
+
46
+ ### Instruction:
47
+ You are a helpful assistant. Answer the following question concisely and directly: {message}
48
+
49
+ ### Response:
50
+ """
51
 
52
  # --- GENERATION ---
53
+ # We add "###" to the stop tokens. This cuts off the model immediately
54
+ # if it tries to start generating "Solution 1" or a new "### Instruction".
55
+ stop_tokens = ["</s>", "###", "Solution"]
56
+
57
  output = llm(
58
  prompt,
59
  max_tokens=512,