Spaces:
Running
Running
Utkarsh Verma
commited on
Commit
Β·
0643817
1
Parent(s):
45bb5d9
Code Change
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ def home():
|
|
15 |
return render_template('index.html')
|
16 |
|
17 |
@app.route('/chat', methods=['POST'])
|
18 |
-
def chat(
|
19 |
user_message = request.json.get("message")
|
20 |
|
21 |
if not user_message:
|
@@ -23,8 +23,7 @@ def chat(user_message):
|
|
23 |
|
24 |
try:
|
25 |
payload = {
|
26 |
-
"inputs": f"
|
27 |
-
#"inputs": f"[INST] {user_input} [/INST]",
|
28 |
"parameters": {
|
29 |
"temperature": 0.5, # π₯ Controls randomness (lower = more deterministic)
|
30 |
"top_p": 0.9, # π― Focus on high-probability words
|
@@ -46,7 +45,7 @@ def chat(user_message):
|
|
46 |
|
47 |
if "error" in data:
|
48 |
return jsonify({"reply": f"Error: {data['error']}"})
|
49 |
-
|
50 |
reply = data[0]['generated_text'] if isinstance(data, list) else data.get('generated_text', "No response")
|
51 |
return jsonify({"reply": reply})
|
52 |
|
|
|
15 |
return render_template('index.html')
|
16 |
|
17 |
@app.route('/chat', methods=['POST'])
|
18 |
+
def chat(user_input):
|
19 |
user_message = request.json.get("message")
|
20 |
|
21 |
if not user_message:
|
|
|
23 |
|
24 |
try:
|
25 |
payload = {
|
26 |
+
"inputs": f"[INST] {user_input} [/INST]",
|
|
|
27 |
"parameters": {
|
28 |
"temperature": 0.5, # π₯ Controls randomness (lower = more deterministic)
|
29 |
"top_p": 0.9, # π― Focus on high-probability words
|
|
|
45 |
|
46 |
if "error" in data:
|
47 |
return jsonify({"reply": f"Error: {data['error']}"})
|
48 |
+
|
49 |
reply = data[0]['generated_text'] if isinstance(data, list) else data.get('generated_text', "No response")
|
50 |
return jsonify({"reply": reply})
|
51 |
|