Vedika commited on
Commit
1a274da
·
verified ·
1 Parent(s): 396e86b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -36,6 +36,10 @@ 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 +49,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})
@@ -62,6 +73,7 @@ def chat():
62
  if not content_payload:
63
  content_payload.append({"type": "text", "text": "Hello"})
64
 
 
65
  messages.append({"role": "user", "content": content_payload})
66
 
67
  headers = {
@@ -94,4 +106,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
+
40
+ # 🛠️ FIX 1: यहाँ फ्रंटएंड से आ रही हिस्ट्री को रिसीव किया
41
+ history = data.get("history", [])
42
+
43
  max_tokens = data.get("max_tokens", 4096)
44
  temperature = data.get("temperature", 0.6)
45
 
 
49
  if system_prompt.strip():
50
  messages.append({"role": "system", "content": system_prompt})
51
 
52
+ # 🛠️ FIX 2: पुरानी हिस्ट्र मॉडल के पेलोड में जोड़ा (इससे यह पुरानी बातें याद रखेगा)
53
+ for msg in history:
54
+ role = msg.get("role", "user")
55
+ content = msg.get("content", "")
56
+ if content:
57
+ messages.append({"role": role, "content": content})
58
+
59
+ # 3. मल्टीमोडल इनपुट (करेंट मैसेज)
60
  content_payload = []
61
  if user_message.strip():
62
  content_payload.append({"type": "text", "text": user_message})
 
73
  if not content_payload:
74
  content_payload.append({"type": "text", "text": "Hello"})
75
 
76
+ # नया मैसेज सबसे आखिरी में जोड़ना
77
  messages.append({"role": "user", "content": content_payload})
78
 
79
  headers = {
 
106
  return Response("Internal Error: Unable to process request securely.", status=500)
107
 
108
  if __name__ == '__main__':
109
+ app.run(host='0.0.0.0', port=7860)