mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-09-12 08:29:30 -04:00
Merge pull request #693 from ramonvc/main
Fix: There is no current event loop in thread.
This commit is contained in:
commit
6a34a83cdf
@ -305,19 +305,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):
|
||||
|
Loading…
Reference in New Issue
Block a user