summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiner Lohaus <heiner.lohaus@netformic.com>2023-09-05 17:35:51 +0200
committerHeiner Lohaus <heiner.lohaus@netformic.com>2023-09-05 17:35:51 +0200
commit7a9b7195736153481fd8b50393004e231a3ee7a0 (patch)
treeca506c3c152f3906a5b727a4cc6ebba1fd59d335
parentAdd to many provider async and stream support, Fix Ails, AItianhu, ChatgptAi, ChatgptLogin Provider, Add fallback cookies to Bing, Improve OpenaiChat Provider (diff)
downloadgpt4free-7a9b7195736153481fd8b50393004e231a3ee7a0.tar
gpt4free-7a9b7195736153481fd8b50393004e231a3ee7a0.tar.gz
gpt4free-7a9b7195736153481fd8b50393004e231a3ee7a0.tar.bz2
gpt4free-7a9b7195736153481fd8b50393004e231a3ee7a0.tar.lz
gpt4free-7a9b7195736153481fd8b50393004e231a3ee7a0.tar.xz
gpt4free-7a9b7195736153481fd8b50393004e231a3ee7a0.tar.zst
gpt4free-7a9b7195736153481fd8b50393004e231a3ee7a0.zip
-rw-r--r--g4f/Provider/Bing.py23
-rw-r--r--testing/test_providers.py1
2 files changed, 8 insertions, 16 deletions
diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py
index 179ca29b..05be27e7 100644
--- a/g4f/Provider/Bing.py
+++ b/g4f/Provider/Bing.py
@@ -1,7 +1,10 @@
from __future__ import annotations
-from aiohttp import ClientSession
-from ..typing import Any, AsyncGenerator, Union
+import random
+import json
+import os
+from aiohttp import ClientSession, ClientTimeout
+from ..typing import AsyncGenerator
from .base_provider import AsyncGeneratorProvider, get_cookies
@@ -225,7 +228,7 @@ async def stream_generate(
cookies: dict=None
):
async with ClientSession(
- timeout=aiohttp.ClientTimeout(total=900),
+ timeout=ClientTimeout(total=900),
cookies=cookies,
headers=Defaults.headers,
) as session:
@@ -277,16 +280,4 @@ async def stream_generate(
final = True
break
finally:
- await delete_conversation(session, conversation)
-
-def run(generator: AsyncGenerator[Union[Any, str], Any]):
- loop = asyncio.get_event_loop()
- gen = generator.__aiter__()
-
- while True:
- try:
- yield loop.run_until_complete(gen.__anext__())
-
- except StopAsyncIteration:
- break
-
+ await delete_conversation(session, conversation) \ No newline at end of file
diff --git a/testing/test_providers.py b/testing/test_providers.py
index 676f1a59..be04e7a3 100644
--- a/testing/test_providers.py
+++ b/testing/test_providers.py
@@ -39,6 +39,7 @@ def main():
def get_providers() -> list[type[BaseProvider]]:
provider_names = dir(Provider)
ignore_names = [
+ "annotations",
"base_provider",
"BaseProvider",
"AsyncProvider",