summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Bing.py
diff options
context:
space:
mode:
authorHeiner Lohaus <heiner.lohaus@netformic.com>2023-09-05 17:27:24 +0200
committerHeiner Lohaus <heiner.lohaus@netformic.com>2023-09-05 17:27:24 +0200
commit5ca47b44b2b42abb4f48163c17500b5ee67ab28f (patch)
treeb8fba4bde73d59c05857459eac41b25347d65c8e /g4f/Provider/Bing.py
parent~ | Merge pull request #869 from ahobsonsayers/add-console-script (diff)
downloadgpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar
gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar.gz
gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar.bz2
gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar.lz
gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar.xz
gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar.zst
gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.zip
Diffstat (limited to 'g4f/Provider/Bing.py')
-rw-r--r--g4f/Provider/Bing.py23
1 files changed, 6 insertions, 17 deletions
diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py
index cec82108..179ca29b 100644
--- a/g4f/Provider/Bing.py
+++ b/g4f/Provider/Bing.py
@@ -1,23 +1,14 @@
from __future__ import annotations
-import asyncio
-import json
-import os
-import random
-
-import aiohttp
-from aiohttp import ClientSession
-
-from ..typing import Any, AsyncGenerator, CreateResult, Union
+from aiohttp import ClientSession
+from ..typing import Any, AsyncGenerator, Union
from .base_provider import AsyncGeneratorProvider, get_cookies
class Bing(AsyncGeneratorProvider):
url = "https://bing.com/chat"
- needs_auth = True
working = True
supports_gpt_4 = True
- supports_stream = True
@staticmethod
def create_async_generator(
@@ -34,18 +25,16 @@ class Bing(AsyncGeneratorProvider):
prompt = messages[-1]["content"]
context = create_context(messages[:-1])
- if cookies and "SRCHD" in 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 = {
- 'SRCHD' : cookies["SRCHD"],
+ if not cookies or "SRCHD" not in cookies:
+ cookies = {
+ 'SRCHD' : 'AF=NOFORM',
'PPLState' : '1',
'KievRPSSecAuth': '',
'SUID' : '',
'SRCHUSR' : '',
'SRCHHPGUSR' : '',
}
-
- return stream_generate(prompt, context, cookies_dict)
+ return stream_generate(prompt, context, cookies)
def create_context(messages: list[dict[str, str]]):
context = "".join(f"[{message['role']}](#message)\n{message['content']}\n\n" for message in messages)