Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -10,9 +10,14 @@ HUGGINGFACE_API_KEY = os.getenv("HUGGINGFACE_API_KEY")
|
|
10 |
def get_bot_response(user_input):
|
11 |
headers = {"Authorization": f"Bearer {HUGGINGFACE_API_KEY}"}
|
12 |
response = requests.post(API_URL, headers=headers, json={"inputs": user_input})
|
|
|
|
|
|
|
|
|
|
|
13 |
if response.status_code == 200:
|
14 |
result = response.json()
|
15 |
-
bot_response = result[0]
|
16 |
else:
|
17 |
bot_response = "Sorry, the model is currently unavailable."
|
18 |
return bot_response
|
|
|
10 |
def get_bot_response(user_input):
|
11 |
headers = {"Authorization": f"Bearer {HUGGINGFACE_API_KEY}"}
|
12 |
response = requests.post(API_URL, headers=headers, json={"inputs": user_input})
|
13 |
+
|
14 |
+
# Debugging: print status and response
|
15 |
+
print("Status Code:", response.status_code)
|
16 |
+
print("Response:", response.text)
|
17 |
+
|
18 |
if response.status_code == 200:
|
19 |
result = response.json()
|
20 |
+
bot_response = result[0].get("generated_text", "Sorry, I couldn't generate a response.")
|
21 |
else:
|
22 |
bot_response = "Sorry, the model is currently unavailable."
|
23 |
return bot_response
|