mdpatel2 commited on
Commit
6eef797
·
verified ·
1 Parent(s): 0c5f73c

printing raw response

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -13,14 +13,19 @@ def chat_with_rasa(user_message, history):
13
  )
14
 
15
  try:
16
- bot_messages = response.json()
 
17
  chat_log = history
 
 
 
 
18
  if isinstance(bot_messages, list):
19
- chat_log += f"\nYou: {user_message}"
20
  for msg in bot_messages:
21
  chat_log += f"\nBot: {msg.get('text', 'No response')}"
22
  else:
23
- chat_log += "\nError: Unexpected response type from Rasa."
24
  return chat_log
25
  except ValueError as e:
26
  return f"Error decoding JSON response: {str(e)}"
 
13
  )
14
 
15
  try:
16
+ # Get the raw response content
17
+ raw_response = response.content.decode("utf-8")
18
  chat_log = history
19
+ chat_log += f"\n\nRaw Response:\n{raw_response}"
20
+
21
+ # Attempt to parse JSON response
22
+ bot_messages = response.json()
23
  if isinstance(bot_messages, list):
24
+ chat_log += f"\n\nYou: {user_message}"
25
  for msg in bot_messages:
26
  chat_log += f"\nBot: {msg.get('text', 'No response')}"
27
  else:
28
+ chat_log += "\n\nError: Unexpected response type from Rasa."
29
  return chat_log
30
  except ValueError as e:
31
  return f"Error decoding JSON response: {str(e)}"