Belva1 commited on
Commit
9ecce17
·
verified ·
1 Parent(s): c648b06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
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]["generated_text"]
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