Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,68 +1,39 @@
|
|
1 |
-
from flask import Flask, request, jsonify
|
2 |
import requests
|
3 |
import json
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
chat_response = requests.post(chat_url, headers=chat_headers, json=chat_payload)
|
42 |
-
|
43 |
-
# Check if the response is successful
|
44 |
-
if chat_response.status_code != 200:
|
45 |
-
return jsonify({"error": "Failed to fetch response from DuckDuckGo Chat API."}), chat_response.status_code
|
46 |
-
|
47 |
-
# Process the response
|
48 |
-
response_lines = chat_response.text.splitlines()
|
49 |
-
final_response = ""
|
50 |
-
|
51 |
-
for line in response_lines:
|
52 |
-
try:
|
53 |
-
data = json.loads(line.replace("data: ", ""))
|
54 |
-
if "message" in data:
|
55 |
-
final_response += data["message"]
|
56 |
-
except json.JSONDecodeError:
|
57 |
-
continue
|
58 |
-
final_response = final_response.replace("AI: ", "")
|
59 |
-
final_response = final_response.replace("AI:", "")
|
60 |
-
|
61 |
-
return jsonify({"response": final_response})
|
62 |
-
|
63 |
-
except Exception as e:
|
64 |
-
return jsonify({"error": str(e)}), 500
|
65 |
-
|
66 |
-
|
67 |
-
if __name__ == "__main__":
|
68 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
|
|
1 |
import requests
|
2 |
import json
|
3 |
|
4 |
+
# Define the request URL
|
5 |
+
url = "https://prod-backend-k8s.flowgpt.com/v3/chat"
|
6 |
+
|
7 |
+
# Define the headers
|
8 |
+
headers = {
|
9 |
+
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IklUMU5Lb2ItOFBsY3ZJdGd2NWRIaiIsImVtYWlsIjoiYWxob29yc2hvcHBAZ21haWwuY29tIiwic3ViIjoiSVQxTktvYi04UGxjdkl0Z3Y1ZEhqIiwiaWF0IjoxNzM0MDA2NTczLjQ1OSwiZXhwIjoxNzM0NjExMzczfQ.oWcKiEshQs8HmW33Qyq27YSVDfGhXEcf9_L4TXcULAvHmZgO8u43Nr21ti9gtJ7xT46AGS42ag8OFF0AaEEoo1nvhA-uFEjziG_9sOcml5qf3uagE-3mBHRFmTYaMYN_t0ZgJ54WNd49lDjFeUnwZUna1wHxlNXG5ZelHCO7K7Dv42SAB4kdp5FTBzCtjsdR3Aqjoby83NqeYD6GlwlWS1cUENvjjHmeESGF6Z1Atgbmi29QHShARc0MvX9zi1B4LjXpPspP5c4nj2TyzK6SxfAujzE5r4zICrcFLHQ1-C95SmP-YsIo-jfnFOZw2iI6fQeMQsDUgZ396Xqp2wAOqg",
|
10 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
11 |
+
"x-aws-waf-token": "c4793f6b-6053-4579-9aac-20201e40a3c7:EgoAv3JYmYYAAgAA:/LldKzen8O3QvI/ZxhLDujp8q3rJiPMGNWmGf3dwCoMfvoIImxhyxVIyHtllJ+dgNWpOGvLLD+bB9SMVg4Tf/VK+5wBSf8g7ATgIJ5y4gE1hiTDxZe6Zpab5QglNY7mtMkuzIsvBlqiDip4DtzOeA03d8C5LT7Y0Ea1/tU/O+Pjq/SncnArmsF3ztj60aN6uCfJ3Vh2/m97TkOw4IWMbRRD9kkelx7Uvqy1POgF/D0qI+OfhMad7MKMsFg==",
|
12 |
+
"x-flow-device-id": "xqGy17TUy56Ekt4Nsr4np",
|
13 |
+
"x-nonce": "6bb24d8ce5e09df641c8217f250bd8ab",
|
14 |
+
"x-signature": "a0f9a9350d566b207804d722421f8914",
|
15 |
+
"x-timestamp": "1734007773"
|
16 |
+
}
|
17 |
+
|
18 |
+
# Define the payload
|
19 |
+
payload = {
|
20 |
+
"documentIds": [],
|
21 |
+
"generateAudio": True,
|
22 |
+
"generateImage": False,
|
23 |
+
"history": [{"role": "assistant", "content": "Hello There !"}],
|
24 |
+
"content": "Hello There !",
|
25 |
+
"role": "assistant",
|
26 |
+
"model": "deepseek-chat",
|
27 |
+
"nsfw": False,
|
28 |
+
"promptId": "O9jUyVB4crxHKegm6stS6",
|
29 |
+
"question": "اهلا",
|
30 |
+
"system": "you are AI Model From Libyan Team (CORVO AI)\n\nyou are the next model after ALEX-9\n\nand your current name is ALEX-9 Pro\n\nchat with users and be Funny smart and powerful OF AI",
|
31 |
+
"temperature": 0.7,
|
32 |
+
"userId": "IT1NKob-8PlcvItgv5dHj"
|
33 |
+
}
|
34 |
+
|
35 |
+
# Send the POST request
|
36 |
+
response = requests.post(url, headers=headers, json=payload)
|
37 |
+
|
38 |
+
# Print the response text
|
39 |
+
print(response.text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|