Fix: There is no current event loop in thread.

This commit is contained in:
Ramon Victor Cardoso 2023-06-27 13:30:18 -03:00
parent 945f2feee4
commit f89fa75176
1 changed files with 13 additions and 12 deletions

View File

@ -304,19 +304,20 @@ async def stream_generate(prompt: str, mode: optionsSets.optionSet = optionsSets
await session.close()
def run(generator):
loop = asyncio.get_event_loop()
gen = generator.__aiter__()
def run(generator):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
gen = generator.__aiter__()
while True:
try:
next_val = loop.run_until_complete(gen.__anext__())
yield next_val
except StopAsyncIteration:
break
#print('Done')
while True:
try:
next_val = loop.run_until_complete(gen.__anext__())
yield next_val
except StopAsyncIteration:
break
#print('Done')
def convert(messages):