summaryrefslogtreecommitdiffstats
path: root/g4f/providers
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/providers')
-rw-r--r--g4f/providers/base_provider.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/g4f/providers/base_provider.py b/g4f/providers/base_provider.py
index 5624c9e1..d6c24387 100644
--- a/g4f/providers/base_provider.py
+++ b/g4f/providers/base_provider.py
@@ -30,6 +30,13 @@ if sys.platform == 'win32':
def get_running_loop(check_nested: bool) -> Union[AbstractEventLoop, None]:
try:
loop = asyncio.get_running_loop()
+ # Do not patch uvloop loop because its incompatible.
+ try:
+ import uvloop
+ if isinstance(loop, uvloop.Loop):
+ return
+ except (ImportError, ModuleNotFoundError):
+ pass
if check_nested and not hasattr(loop.__class__, "_nest_patched"):
try:
import nest_asyncio
@@ -290,4 +297,4 @@ class ProviderModelMixin:
elif model not in cls.get_models() and cls.models:
raise ModelNotSupportedError(f"Model is not supported: {model} in: {cls.__name__}")
debug.last_model = model
- return model \ No newline at end of file
+ return model