summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Bing.py
diff options
context:
space:
mode:
authorLuneye <73485421+Luneye@users.noreply.github.com>2023-08-28 16:55:36 +0200
committerGitHub <noreply@github.com>2023-08-28 16:55:36 +0200
commit01294db6995511de37e9078e03ce32e54dbdad52 (patch)
treed6c4c14f4e6a3a81660ddb75272bc5da81cacecc /g4f/Provider/Bing.py
parentUpdate Bing.py (diff)
parent~ | code styling (diff)
downloadgpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar.gz
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar.bz2
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar.lz
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar.xz
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar.zst
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.zip
Diffstat (limited to 'g4f/Provider/Bing.py')
-rw-r--r--g4f/Provider/Bing.py33
1 files changed, 14 insertions, 19 deletions
diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py
index d96af6a6..88394f70 100644
--- a/g4f/Provider/Bing.py
+++ b/g4f/Provider/Bing.py
@@ -1,36 +1,31 @@
-import asyncio, json, os, random, aiohttp
+import asyncio, aiohttp, json, os, random
-from aiohttp import ClientSession
-
-from ..typing import Any, AsyncGenerator, CreateResult, Union
+from aiohttp import ClientSession
+from ..typing import Any, AsyncGenerator, CreateResult, Union
from .base_provider import AsyncGeneratorProvider, get_cookies
class Bing(AsyncGeneratorProvider):
- url = "https://bing.com/chat"
- supports_gpt_4 = True
- working=True
- supports_stream=True
- needs_auth=True
-
+ url = "https://bing.com/chat"
+ needs_auth = True
+ working = True
+ supports_gpt_4 = True
+ supports_stream = True
+
@staticmethod
- def create_completion(
- model: str,
- messages: list[dict[str, str]],
- cookies: dict,
- **kwargs
- ) -> AsyncGenerator:
+ def create_async_generator(
+ model: str,
+ messages: list[dict[str, str]],
+ cookies: dict = get_cookies(".bing.com"), **kwargs) -> AsyncGenerator:
if len(messages) < 2:
prompt = messages[0]["content"]
context = None
-
else:
prompt = messages[-1]["content"]
context = create_context(messages[:-1])
if cookies:
#TODO: Will implement proper cookie retrieval later and use a try-except mechanism in 'stream_generate' instead of defaulting the cookie value like this
- #cookies_dict = get_cookies(".bing.com")
cookies_dict = {
'MUID': '',
'BCP': '',
@@ -313,4 +308,4 @@ def run(generator: AsyncGenerator[Union[Any, str], Any]):
yield loop.run_until_complete(gen.__anext__())
except StopAsyncIteration:
- break
+ break \ No newline at end of file