Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

Commit ca5e10b

Browse files
authored
Fix compatibility with Copilot API (#139)
- Update bundle version - Update user agent - Update request headers - Update request URLs - Improve testing
1 parent ceae28f commit ca5e10b

File tree

6 files changed

+140
-23
lines changed

6 files changed

+140
-23
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ jobs:
4141
run: poetry run mypy --ignore-missing-imports sydney/
4242

4343
- name: Run tests
44-
run: poetry run pytest --cov --reruns 2
44+
run: poetry run pytest --cov --reruns 3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# <img src="https://raw.githubusercontent.com/vsakkas/sydney.py/master/images/logo.svg" width="28px" /> Sydney.py
22

3-
[![Latest Release](https://img.shields.io/github/v/release/vsakkas/sydney.py.svg)](https://github.com/vsakkas/sydney.py/releases/tag/v0.20.0)
3+
[![Latest Release](https://img.shields.io/github/v/release/vsakkas/sydney.py.svg)](https://github.com/vsakkas/sydney.py/releases/tag/v0.20.1)
44
[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
55
[![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/vsakkas/sydney.py/blob/master/LICENSE)
66

poetry.lock

Lines changed: 93 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "sydney-py"
3-
version = "0.20.0"
3+
version = "0.20.1"
44
description = "Python Client for Copilot (formerly named Bing Chat), also known as Sydney."
55
authors = ["vsakkas <[email protected]>"]
66
license = "MIT"
@@ -11,6 +11,7 @@ packages = [{ include = "sydney" }]
1111
python = "^3.9"
1212
aiohttp = "^3.8.6"
1313
websockets = "^11.0.3"
14+
brotli = "^1.1.0"
1415

1516
[tool.poetry.group.dev.dependencies]
1617
black = "^23.10.1"

sydney/constants.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.2151.72"
1+
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.2210.91"
22

33
CREATE_HEADERS = {
44
"Accept": "application/json",
5+
"Accept-Encoding": "gzip, deflate, br",
56
"Accept-Language": "en-US,en;q=0.9",
6-
"Referer": "https://www.bing.com/copilot",
7-
"Sec-Ch-Ua": '"Microsoft Edge";v="119", "Chromium";v="119", "Not?A_Brand";v="8"',
7+
"Referer": "https://copilot.microsoft.com/",
8+
"Sec-Ch-Ua": '"Microsoft Edge";v="120", "Chromium";v="120", "Not?A_Brand";v="8"',
89
"Sec-Ch-Ua-Mobile": "?0",
910
"Sec-Ch-Ua-Platform": "Windows",
1011
"Sec-Fetch-Dest": "empty",
@@ -15,29 +16,37 @@
1516
}
1617

1718
CHATHUB_HEADERS = {
18-
"Pragma": "no-cache",
19-
"Origin": "https://www.bing.com",
19+
"Accept-Encoding": "gzip, deflate, br",
2020
"Accept-Language": "en-US,en;q=0.9",
21-
"User-Agent": USER_AGENT,
2221
"Cache-Control": "no-cache",
2322
"Connection": "Upgrade",
23+
"Origin": "https://copilot.microsoft.com",
24+
"Pragma": "no-cache",
25+
"User-Agent": USER_AGENT,
2426
}
2527

2628
KBLOB_HEADERS = {
29+
"Accept": "image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",
30+
"Accept-Encoding": "gzip, deflate, br",
2731
"Accept-Language": "en-US,en;q=0.5",
2832
"Content-Type": "multipart/form-data",
29-
"Referer": "https://www.bing.com/",
33+
"Referer": "https://copilot.microsoft.com/",
34+
"Sec-Ch-Ua": '"Microsoft Edge";v="120", "Chromium";v="120", "Not?A_Brand";v="8"',
35+
"Sec-Ch-Ua-Mobile": "?0",
36+
"Sec-Ch-Ua-Platform": "Windows",
37+
"Sec-Fetch-Dest": "empty",
38+
"Sec-Fetch-Mode": "cors",
39+
"Sec-Fetch-Site": "same-origin",
3040
"User-Agent": USER_AGENT,
41+
"X-Edge-Shopping-Flag": "0",
3142
}
3243

33-
BUNDLE_VERSION = "1.1342.3-cplt.7"
44+
BUNDLE_VERSION = "1.1381.12"
3445

35-
BING_CREATE_CONVERSATION_URL = (
36-
f"https://www.bing.com/turing/conversation/create?bundleVersion={BUNDLE_VERSION}"
37-
)
46+
BING_CREATE_CONVERSATION_URL = f"https://edgeservices.bing.com/edgesvc/turing/conversation/create?bundleVersion={BUNDLE_VERSION}"
3847
BING_GET_CONVERSATIONS_URL = "https://www.bing.com/turing/conversation/chats"
3948
BING_CHATHUB_URL = "wss://sydney.bing.com/sydney/ChatHub"
40-
BING_KBLOB_URL = "https://www.bing.com/images/kblob"
41-
BING_BLOB_URL = "https://www.bing.com/images/blob?bcid="
49+
BING_KBLOB_URL = "https://copilot.microsoft.com/images/kblob"
50+
BING_BLOB_URL = "https://copilot.microsoft.com/images/blob?bcid="
4251

4352
DELIMETER = "\x1e" # Record separator character.

0 commit comments

Comments
 (0)