YKajima commited on
Commit
4e98579
·
verified ·
1 Parent(s): 1c4b1b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -34,10 +34,11 @@ async def summarize(text: str):
34
 
35
  def chat(text):
36
  loop = asyncio.new_event_loop()
37
- summary = loop.run_until_complete(summarize(text))
38
- loop.close()
39
- return summary
40
-
 
41
 
42
  iface = gr.Interface(fn=chat, inputs="text", outputs="text")
43
 
 
34
 
35
  def chat(text):
36
  loop = asyncio.new_event_loop()
37
+ if loop.is_running():
38
+ return await summarize(text)
39
+ else:
40
+ return asyncio.run(summarize(text))
41
+
42
 
43
  iface = gr.Interface(fn=chat, inputs="text", outputs="text")
44