返回提交历史
Modified
README.md
+1
-1
Modified
g4f/Provider/Bing.py
+34
-8
Modified
g4f/__init__.py
+1
-1
Modified
setup.py
+1
-1
XFEstudio/gpt4free
~ | g4f v-0.1.4.8 - Fixed `g4f.Provider.Bing`
implemented new "X-Sydney-EncryptedConversationSignature" found in headers from "turing/conversation/create"
0bd5730b
代码差异
4 个文件
+37
-11
@@ -4,7 +4,7 @@ By using this repository or any code related to it, you agree to the [legal noti
4
4
5
5
### New
6
6
- official website: *https://g4f.ai*
7
- latest pypi version: ([0.1.4.7](https://pypi.org/project/g4f/0.1.4.7)):
7
- latest pypi version: ([0.1.4.8](https://pypi.org/project/g4f/0.1.4.8)):
8
8
```sh
9
9
pip install -U g4f
10
10
```
@@ -1,6 +1,7 @@
1
1
from __future__ import annotations
2
2
3
3
import random
4
import uuid
4
5
import json
5
6
import os
6
7
import urllib.parse
@@ -57,14 +58,39 @@ class Conversation():
57
58
self.conversationSignature = conversationSignature
58
59
59
60
async def create_conversation(session: ClientSession) -> Conversation:
60
url = 'https://www.bing.com/turing/conversation/create'
61
async with await session.get(url) as response:
62
response = await response.json()
61
url = 'https://www.bing.com/turing/conversation/create?bundleVersion=1.1055.6'
62
headers = {
63
'authority': 'www.bing.com',
64
'accept': 'application/json',
65
'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
66
'cache-control': 'no-cache',
67
'pragma': 'no-cache',
68
'referer': 'https://www.bing.com/search?q=Bing+AI&showconv=1',
69
'sec-ch-ua': '"Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"',
70
'sec-ch-ua-arch': '"arm"',
71
'sec-ch-ua-bitness': '"64"',
72
'sec-ch-ua-full-version': '"117.0.5938.132"',
73
'sec-ch-ua-full-version-list': '"Google Chrome";v="117.0.5938.132", "Not;A=Brand";v="8.0.0.0", "Chromium";v="117.0.5938.132"',
74
'sec-ch-ua-mobile': '?0',
75
'sec-ch-ua-model': '""',
76
'sec-ch-ua-platform': '"macOS"',
77
'sec-ch-ua-platform-version': '"14.0.0"',
78
'sec-fetch-dest': 'empty',
79
'sec-fetch-mode': 'cors',
80
'sec-fetch-site': 'same-origin',
81
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
82
'x-ms-client-request-id': str(uuid.uuid4()),
83
'x-ms-useragent': 'azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.12.0 OS/macOS',
84
}
85
86
async with await session.get(url, headers=headers) as response:
87
conversationSignature = response.headers.get('X-Sydney-EncryptedConversationSignature', '')
88
89
response = await response.json()
63
90
conversationId = response.get('conversationId')
64
clientId = response.get('clientId')
65
conversationSignature = response.get('conversationSignature')
66
67
if not conversationId or not clientId or not conversationSignature:
91
clientId = response.get('clientId')
92
93
if not conversationId or not clientId:
68
94
raise Exception('Failed to create conversation.')
69
95
70
96
return Conversation(conversationId, clientId, conversationSignature)
@@ -249,7 +275,7 @@ async def stream_generate(
249
275
conversation = await retry_conversation(session)
250
276
try:
251
277
async with session.ws_connect(
252
'wss://sydney.bing.com/sydney/ChatHub',
278
f'wss://sydney.bing.com/sydney/ChatHub?sec_access_token={urllib.parse.quote_plus(conversation.conversationSignature)}',
253
279
autoping=False,
254
280
) as wss:
255
281
@@ -5,7 +5,7 @@ from .typing import Any, CreateResult, Union
5
5
from requests import get
6
6
7
7
logging = False
8
version = '0.1.4.7'
8
version = '0.1.4.8'
9
9
10
10
def check_pypi_version():
11
11
try:
@@ -14,7 +14,7 @@ with open("requirements.txt") as f:
14
14
with open("interference/requirements.txt") as f:
15
15
api_required = f.read().splitlines()
16
16
17
VERSION = '0.1.4.7'
17
VERSION = '0.1.4.8'
18
18
DESCRIPTION = (
19
19
"The official gpt4free repository | various collection of powerful language models"
20
20
)