Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,20 +5,22 @@ import requests
|
|
5 |
url = "https://fric7ion-fricfast.hf.space/chat"
|
6 |
|
7 |
def chatgpt(message, history):
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
21 |
return reply
|
|
|
22 |
iface = gr.Blocks()
|
23 |
|
24 |
with iface:
|
|
|
5 |
url = "https://fric7ion-fricfast.hf.space/chat"
|
6 |
|
7 |
def chatgpt(message, history):
|
8 |
+
try:
|
9 |
+
# Attempt to make the external request
|
10 |
+
response = requests.post(url, params={"prompt": message, "max_token": "140"})
|
11 |
+
print("Raw response:", response.text)
|
12 |
+
if response.text:
|
13 |
+
data = response.json()
|
14 |
+
print(data)
|
15 |
+
reply = data.get('message', '')
|
16 |
+
else:
|
17 |
+
print("Empty response")
|
18 |
+
reply = "Error: No response from server"
|
19 |
+
except Exception as e:
|
20 |
+
print("Error making external request:", e)
|
21 |
+
reply = "Error: Unable to process request"
|
22 |
return reply
|
23 |
+
|
24 |
iface = gr.Blocks()
|
25 |
|
26 |
with iface:
|