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,15 @@ 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})
|
|
|
|
| 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. पुरानी हिस्ट्री लोड करना (यही मिसिंग था)
|
| 50 |
+
for msg in history:
|
| 51 |
+
# फ्रंटएंड 'bot' भेजता है, लेकिन मॉडल को 'assistant' चाहिए होता है
|
| 52 |
+
role = "assistant" if msg.get("role") == "bot" else "user"
|
| 53 |
+
content = msg.get("content", "")
|
| 54 |
+
if content:
|
| 55 |
+
messages.append({"role": role, "content": content})
|
| 56 |
+
|
| 57 |
+
# 3. मल्टीमोडल इनपुट (करंट मैसेज)
|
| 58 |
content_payload = []
|
| 59 |
if user_message.strip():
|
| 60 |
content_payload.append({"type": "text", "text": user_message})
|