mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-09-12 08:29:30 -04:00
Fix: There is no current event loop in thread.
This commit is contained in:
parent
945f2feee4
commit
f89fa75176
@ -304,19 +304,20 @@ async def stream_generate(prompt: str, mode: optionsSets.optionSet = optionsSets
|
|||||||
await session.close()
|
await session.close()
|
||||||
|
|
||||||
|
|
||||||
def run(generator):
|
def run(generator):
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.new_event_loop()
|
||||||
gen = generator.__aiter__()
|
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):
|
def convert(messages):
|
||||||
|
Loading…
Reference in New Issue
Block a user