summaryrefslogtreecommitdiffstats
path: root/g4f/providers/base_provider.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-05-20 15:24:45 +0200
committerGitHub <noreply@github.com>2024-05-20 15:24:45 +0200
commitf956288780975ff54bd14b3c42a679ed19aa9483 (patch)
treefe9e1ad867d90fcce07c6e90f9a3a6f9495f85d2 /g4f/providers/base_provider.py
parentMerge pull request #1984 from hlohaus/leech (diff)
parentUpdate base_provider.py (diff)
downloadgpt4free-f956288780975ff54bd14b3c42a679ed19aa9483.tar
gpt4free-f956288780975ff54bd14b3c42a679ed19aa9483.tar.gz
gpt4free-f956288780975ff54bd14b3c42a679ed19aa9483.tar.bz2
gpt4free-f956288780975ff54bd14b3c42a679ed19aa9483.tar.lz
gpt4free-f956288780975ff54bd14b3c42a679ed19aa9483.tar.xz
gpt4free-f956288780975ff54bd14b3c42a679ed19aa9483.tar.zst
gpt4free-f956288780975ff54bd14b3c42a679ed19aa9483.zip
Diffstat (limited to 'g4f/providers/base_provider.py')
-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..a03dcbba 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 loop
+ 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