Replies: 2 comments
-
|
you can do something like that : async def ask(model,prompt,timeout=30):
coro = g4f.ChatCompletion.create_async(
messages=[ dict(role="user",content=prompt) ],
model=model,
)
try:
return True, await asyncio.wait_for(coro,timeout=timeout)
except asyncio.TimeoutError:
return (False, f"TIMEOUT > {timeout}")
except Exception as e:
return (False,str(e)) |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Thaks a lot! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Some of the providers started give answers in a very long time - up to 200-300 seconds.
Is there any way to stop request by timeout?
Beta Was this translation helpful? Give feedback.
All reactions