From c751da0b33707627e1bb82e0e4abb20eb7ac7eb1 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Wed, 14 Feb 2024 09:32:49 +0100 Subject: Delete image.html --- image.html | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 image.html diff --git a/image.html b/image.html deleted file mode 100644 index d774b373..00000000 --- a/image.html +++ /dev/null @@ -1,3 +0,0 @@ -
a serene garden filled with colorful flowers in full bloom
DesignerDesigner
Powered by DALL·E 3
\ No newline at end of file -- cgit v1.2.3 From 7cd5b3f0c639578dcdaeb354e1071172a7d7f761 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Sat, 17 Feb 2024 22:36:31 +0100 Subject: Improve create conversation in Bing --- g4f/Provider/Bing.py | 6 +++--- g4f/Provider/bing/conversation.py | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py index 5b5f89aa..1e29c4f1 100644 --- a/g4f/Provider/Bing.py +++ b/g4f/Provider/Bing.py @@ -66,7 +66,7 @@ class Bing(AsyncGeneratorProvider): prompt = messages[-1]["content"] context = create_context(messages[:-1]) - cookies = {**Defaults.cookies, **cookies} if cookies else Defaults.cookies + cookies = {**get_default_cookies(), **cookies} if cookies else get_default_cookies() gpt4_turbo = True if model.startswith("gpt-4-turbo") else False @@ -146,8 +146,8 @@ class Defaults: "streamf", "codeint", "langdtwb", "fdwtlst", "fluxprod", "deuct3" ] - # Default cookies - cookies = { +def get_default_cookies(): + return { 'SRCHD' : 'AF=NOFORM', 'PPLState' : '1', 'KievRPSSecAuth': '', diff --git a/g4f/Provider/bing/conversation.py b/g4f/Provider/bing/conversation.py index 388bdd6b..fb95e241 100644 --- a/g4f/Provider/bing/conversation.py +++ b/g4f/Provider/bing/conversation.py @@ -1,5 +1,6 @@ from __future__ import annotations +import uuid from aiohttp import ClientSession class Conversation: @@ -30,8 +31,20 @@ async def create_conversation(session: ClientSession, proxy: str = None) -> Conv Returns: Conversation: An instance representing the created conversation. """ - url = 'https://www.bing.com/turing/conversation/create?bundleVersion=1.1199.4' + url = 'https://www.bing.com/search?toncp=0&FORM=hpcodx&q=Bing+AI&showconv=1&cc=en' async with session.get(url, proxy=proxy) as response: + response.raise_for_status() + headers = { + "accept": "application/json", + "sec-fetch-dest": "empty", + "sec-fetch-mode": "cors", + "sec-fetch-site": "same-origin", + "x-ms-client-request-id": str(uuid.uuid4()), + "x-ms-useragent": "azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.12.3 OS/Windows", + "referer": url + } + url = 'https://www.bing.com/turing/conversation/create?bundleVersion=1.1579.2' + async with session.get(url, headers=headers, proxy=proxy) as response: try: data = await response.json() except: -- cgit v1.2.3