lhoestq HF Staff commited on
Commit
7cc69a4
·
verified ·
1 Parent(s): 8d9abf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -76,11 +76,11 @@ def chat_get(message: str = "", system_message: str = "You are a friendly Chatbo
76
  predict_response = requests.post('http://localhost:7860/call/chat', json={'data': [message, {}, system_message, max_tokens, temperature, top_p]}).json()
77
  if "event_id" not in predict_response:
78
  return predict_response
79
- return JSONResponse(json.loads(
80
  requests.get(
81
  f'http://localhost:7860/call/chat/{predict_response["event_id"]}'
82
  ).text.rsplit("\n\nevent: error", 1)[0].rsplit("event: generating\ndata: ", 1)[-1]
83
- )[0].strip())
84
 
85
  if __name__ == "__main__":
86
  app = gr.mount_gradio_app(app, demo, path="/")
 
76
  predict_response = requests.post('http://localhost:7860/call/chat', json={'data': [message, {}, system_message, max_tokens, temperature, top_p]}).json()
77
  if "event_id" not in predict_response:
78
  return predict_response
79
+ return JSONResponse([json.loads(
80
  requests.get(
81
  f'http://localhost:7860/call/chat/{predict_response["event_id"]}'
82
  ).text.rsplit("\n\nevent: error", 1)[0].rsplit("event: generating\ndata: ", 1)[-1]
83
+ )[0].strip()])
84
 
85
  if __name__ == "__main__":
86
  app = gr.mount_gradio_app(app, demo, path="/")