Spaces:
Running
Running
Vedika commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,6 +36,7 @@ def chat():
|
|
| 36 |
user_message = data.get("message", "")
|
| 37 |
attachments = data.get("attachments", [])
|
| 38 |
system_prompt = data.get("system_prompt", "")
|
|
|
|
| 39 |
max_tokens = data.get("max_tokens", 4096)
|
| 40 |
temperature = data.get("temperature", 0.6)
|
| 41 |
|
|
@@ -45,7 +46,14 @@ def chat():
|
|
| 45 |
if system_prompt.strip():
|
| 46 |
messages.append({"role": "system", "content": system_prompt})
|
| 47 |
|
| 48 |
-
# 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
content_payload = []
|
| 50 |
if user_message.strip():
|
| 51 |
content_payload.append({"type": "text", "text": user_message})
|
|
@@ -94,4 +102,4 @@ def chat():
|
|
| 94 |
return Response("Internal Error: Unable to process request securely.", status=500)
|
| 95 |
|
| 96 |
if __name__ == '__main__':
|
| 97 |
-
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 36 |
user_message = data.get("message", "")
|
| 37 |
attachments = data.get("attachments", [])
|
| 38 |
system_prompt = data.get("system_prompt", "")
|
| 39 |
+
history = data.get("history", []) # <-- यहाँ मैंने हिस्ट्री को रिसीव करने का कोड जोड़ा है
|
| 40 |
max_tokens = data.get("max_tokens", 4096)
|
| 41 |
temperature = data.get("temperature", 0.6)
|
| 42 |
|
|
|
|
| 46 |
if system_prompt.strip():
|
| 47 |
messages.append({"role": "system", "content": system_prompt})
|
| 48 |
|
| 49 |
+
# 2. पुरानी हिस्ट्री (Memory) जोड़ना ताकि अर्जुन पुरानी बातें याद रखे <-- यह ब्लॉक नया जोड़ा गया है
|
| 50 |
+
for msg in history:
|
| 51 |
+
role = msg.get("role", "user")
|
| 52 |
+
content = msg.get("content", "")
|
| 53 |
+
if content:
|
| 54 |
+
messages.append({"role": role, "content": content})
|
| 55 |
+
|
| 56 |
+
# 3. मल्टीमोडल इनपुट (करेंट मैसेज)
|
| 57 |
content_payload = []
|
| 58 |
if user_message.strip():
|
| 59 |
content_payload.append({"type": "text", "text": user_message})
|
|
|
|
| 102 |
return Response("Internal Error: Unable to process request securely.", status=500)
|
| 103 |
|
| 104 |
if __name__ == '__main__':
|
| 105 |
+
app.run(host='0.0.0.0', port=7860)
|