返回提交历史
Modified
g4f/Provider/Bing.py
+3
-3
Modified
g4f/Provider/bing/conversation.py
+14
-1
XFEstudio/gpt4free
Improve create conversation in Bing
7cd5b3f0
代码差异
2 个文件
+17
-4
@@ -66,7 +66,7 @@ class Bing(AsyncGeneratorProvider):
66
66
prompt = messages[-1]["content"]
67
67
context = create_context(messages[:-1])
68
68
69
cookies = {**Defaults.cookies, **cookies} if cookies else Defaults.cookies
69
cookies = {**get_default_cookies(), **cookies} if cookies else get_default_cookies()
70
70
71
71
gpt4_turbo = True if model.startswith("gpt-4-turbo") else False
72
72
@@ -146,8 +146,8 @@ class Defaults:
146
146
"streamf", "codeint", "langdtwb", "fdwtlst", "fluxprod", "deuct3"
147
147
]
148
148
149
# Default cookies
150
cookies = {
149
def get_default_cookies():
150
return {
151
151
'SRCHD' : 'AF=NOFORM',
152
152
'PPLState' : '1',
153
153
'KievRPSSecAuth': '',
@@ -1,5 +1,6 @@
1
1
from __future__ import annotations
2
2
3
import uuid
3
4
from aiohttp import ClientSession
4
5
5
6
class Conversation:
@@ -30,8 +31,20 @@ async def create_conversation(session: ClientSession, proxy: str = None) -> Conv
30
31
Returns:
31
32
Conversation: An instance representing the created conversation.
32
33
"""
33
url = 'https://www.bing.com/turing/conversation/create?bundleVersion=1.1199.4'
34
url = 'https://www.bing.com/search?toncp=0&FORM=hpcodx&q=Bing+AI&showconv=1&cc=en'
34
35
async with session.get(url, proxy=proxy) as response:
36
response.raise_for_status()
37
headers = {
38
"accept": "application/json",
39
"sec-fetch-dest": "empty",
40
"sec-fetch-mode": "cors",
41
"sec-fetch-site": "same-origin",
42
"x-ms-client-request-id": str(uuid.uuid4()),
43
"x-ms-useragent": "azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.12.3 OS/Windows",
44
"referer": url
45
}
46
url = 'https://www.bing.com/turing/conversation/create?bundleVersion=1.1579.2'
47
async with session.get(url, headers=headers, proxy=proxy) as response:
35
48
try:
36
49
data = await response.json()
37
50
except: