Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,29 @@
|
|
1 |
import requests
|
2 |
-
import json
|
3 |
|
4 |
-
#
|
5 |
-
url = "https://huggingface.co/chat/conversation"
|
|
|
|
|
6 |
headers = {
|
7 |
"Content-Type": "application/json",
|
8 |
"Cookie": "token=LdeOqPFByfVHXYRcTqdmowtNLCxediADEHZFBibXkaZcHYHtMrYKFEPndUUEyPFTajezjuHTHeStDeabkwbMUoLKzpCFmhmZSIFKvvwWiWHSFdNfoRVKbWuIVTLikIdR; __stripe_mid=06f6506e-e1bc-41c6-88f9-a8b3802c925085fa8e; hf-chat=8881bae7-9647-4cf3-8f8a-59de9f530c82; aws-waf-token=c27f90fe-f8c3-4742-90c7-68e483c93599:DgoAdG6NUVMZAAAA:r3I9urfTNs3M0F/LjKVi3zAL+W3UZ75yLE9SiEnPGsQYZP0qzmo+WNCDXxIacFoPHw5nNHpjZ4dQST/YIFy7vKeVv/fYbrruLJXXYULp2eIxZjmMqmQWZBBqEulrGWvuKpBWymHxyVlJxw6lysVg5ef1amEXPJzaVwdaRiYsNipGTPdiokAbL9k1wunKnirpX3cg3QN9LFeejYP/ZYbiaIciKlxtmnZ+Dlqd5/lh7Uw4jobTLNBRMRN67qZZyooQhmQbW4E="
|
9 |
}
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
"model": "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
|
14 |
-
"preprompt": ""
|
15 |
-
}
|
16 |
-
|
17 |
-
# Make the POST request
|
18 |
-
response = requests.post(url, headers=headers, data=json.dumps(payload))
|
19 |
|
20 |
# Check if the request was successful
|
21 |
if response.status_code == 200:
|
22 |
-
#
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
else:
|
25 |
-
print(f"
|
26 |
-
print(response.text)
|
27 |
-
print(response.json)
|
|
|
1 |
import requests
|
|
|
2 |
|
3 |
+
# Set the URL for the JSON data
|
4 |
+
url = "https://huggingface.co/chat/conversation/672e39722a50f233e983f602/__data.json?x-sveltekit-invalidated=01"
|
5 |
+
|
6 |
+
# Define headers, including the User-Agent
|
7 |
headers = {
|
8 |
"Content-Type": "application/json",
|
9 |
"Cookie": "token=LdeOqPFByfVHXYRcTqdmowtNLCxediADEHZFBibXkaZcHYHtMrYKFEPndUUEyPFTajezjuHTHeStDeabkwbMUoLKzpCFmhmZSIFKvvwWiWHSFdNfoRVKbWuIVTLikIdR; __stripe_mid=06f6506e-e1bc-41c6-88f9-a8b3802c925085fa8e; hf-chat=8881bae7-9647-4cf3-8f8a-59de9f530c82; aws-waf-token=c27f90fe-f8c3-4742-90c7-68e483c93599:DgoAdG6NUVMZAAAA:r3I9urfTNs3M0F/LjKVi3zAL+W3UZ75yLE9SiEnPGsQYZP0qzmo+WNCDXxIacFoPHw5nNHpjZ4dQST/YIFy7vKeVv/fYbrruLJXXYULp2eIxZjmMqmQWZBBqEulrGWvuKpBWymHxyVlJxw6lysVg5ef1amEXPJzaVwdaRiYsNipGTPdiokAbL9k1wunKnirpX3cg3QN9LFeejYP/ZYbiaIciKlxtmnZ+Dlqd5/lh7Uw4jobTLNBRMRN67qZZyooQhmQbW4E="
|
10 |
}
|
11 |
|
12 |
+
# Fetch the JSON data from the URL with the specified headers
|
13 |
+
response = requests.get(url, headers=headers)
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Check if the request was successful
|
16 |
if response.status_code == 200:
|
17 |
+
# Parse the JSON data
|
18 |
+
data = response.json()
|
19 |
+
|
20 |
+
# Attempt to extract the ID
|
21 |
+
try:
|
22 |
+
id_value = data['nodes'][1]['data'][3]
|
23 |
+
print("Extracted ID:", id_value)
|
24 |
+
except KeyError as e:
|
25 |
+
print(f"KeyError: {e}")
|
26 |
+
except IndexError as e:
|
27 |
+
print(f"IndexError: {e}")
|
28 |
else:
|
29 |
+
print(f"Failed to retrieve data: {response.status_code}")
|
|
|
|