Pavithiran commited on
Commit
f150545
·
verified ·
1 Parent(s): e586e56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -38,18 +38,17 @@ def respond(
38
  ):
39
  token = message.choices[0].delta.content
40
 
41
- # Check if the token is a valid JSON string
42
  try:
43
  json.loads(token)
44
  except json.JSONDecodeError:
45
- yield f"Error: Invalid JSON response - {token}"
46
  break
47
 
48
  response += token
49
  yield response
50
  except Exception as e:
51
  yield f"Error: {e}"
52
-
53
  """
54
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
55
  """
 
38
  ):
39
  token = message.choices[0].delta.content
40
 
41
+ # If the token is not a valid JSON string, yield it as is
42
  try:
43
  json.loads(token)
44
  except json.JSONDecodeError:
45
+ yield token
46
  break
47
 
48
  response += token
49
  yield response
50
  except Exception as e:
51
  yield f"Error: {e}"
 
52
  """
53
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
54
  """