Spaces:
Sleeping
Sleeping
Utkarsh Verma
commited on
Commit
Β·
688b851
1
Parent(s):
6dd3dbf
Code Change
Browse files
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": ["
|
| 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 |
-
|
| 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:
|