lhoestq HF Staff commited on
Commit
417e334
·
verified ·
1 Parent(s): ad6ff82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -76,7 +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(requests.get(f'http://localhost:7860/call/chat/{predict_response["event_id"]}').text.rsplit("\n\nevent: error", 1)[0].split("data: ", 1)[-1]))
 
 
 
 
80
 
81
  if __name__ == "__main__":
82
  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="/")