Utkarsh Verma commited on
Commit
688b851
Β·
1 Parent(s): 6dd3dbf

Code Change

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -29,7 +29,7 @@ def chat():
29
  "temperature": 0.5, # πŸ”₯ Controls randomness (lower = more deterministic)
30
  "top_p": 0.9, # 🎯 Focus on high-probability words
31
  "max_new_tokens": 50, # ⏳ Limits response length
32
- "stop_sequences": ["\nUser:", "[INST]"] # β›” Stops response at natural points
33
  }
34
  }
35
  response = requests.post(API_URL, headers=headers, json=payload)
@@ -50,9 +50,7 @@ def chat():
50
  raw_output = data[0]['generated_text'] if isinstance(data, list) else data.get('generated_text', "No response")
51
  reply = raw_output.split("Bot:")[-1].strip()
52
 
53
- # Remove trailing "User" if present
54
- if reply.endswith("User"):
55
- reply = reply[:-4].strip()
56
  return jsonify({"reply": reply})
57
 
58
  except Exception as e:
 
29
  "temperature": 0.5, # πŸ”₯ Controls randomness (lower = more deterministic)
30
  "top_p": 0.9, # 🎯 Focus on high-probability words
31
  "max_new_tokens": 50, # ⏳ Limits response length
32
+ "stop_sequences": ["User:"] # β›” Stops response at natural points
33
  }
34
  }
35
  response = requests.post(API_URL, headers=headers, json=payload)
 
50
  raw_output = data[0]['generated_text'] if isinstance(data, list) else data.get('generated_text', "No response")
51
  reply = raw_output.split("Bot:")[-1].strip()
52
 
53
+
 
 
54
  return jsonify({"reply": reply})
55
 
56
  except Exception as e: