Skip to content

Commit

Permalink
Improve headers compatibility (#154)
Browse files Browse the repository at this point in the history
- Improve header compatibility
- Update bundle version
- Improve upload image compatibility
  • Loading branch information
vsakkas authored Feb 10, 2024
1 parent 42ecdc8 commit 01f5985
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions sydney/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
}

KBLOB_HEADERS = {
"Accept": "image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Language": "en-US,en;q=0.9",
"Content-Type": "multipart/form-data",
"Referer": "https://copilot.microsoft.com/",
"Sec-Ch-Ua": '"Microsoft Edge";v="121", "Chromium";v="121", "Not?A_Brand";v="8"',
Expand All @@ -41,9 +41,11 @@
"X-Edge-Shopping-Flag": "0",
}

BUNDLE_VERSION = "1.1381.12"
BUNDLE_VERSION = "1.1573.2"

BING_CREATE_CONVERSATION_URL = f"https://edgeservices.bing.com/edgesvc/turing/conversation/create?bundleVersion={BUNDLE_VERSION}"
BING_CREATE_CONVERSATION_URL = (
f"https://copilot.microsoft.com/turing/conversation/create?bundleVersion={BUNDLE_VERSION}"
)
BING_GET_CONVERSATIONS_URL = "https://copilot.microsoft.com/turing/conversation/chats"
BING_CHATHUB_URL = "wss://sydney.bing.com/sydney/ChatHub"
BING_KBLOB_URL = "https://copilot.microsoft.com/images/kblob"
Expand Down
4 changes: 2 additions & 2 deletions sydney/sydney.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def _build_upload_arguments(self, attachment: str, image_base64: bytes | None =
data = FormData()

payload = {
"imageInfo": {"url": attachment},
"imageInfo": {} if image_base64 else {"url": attachment},
"knowledgeRequest": {
"invokedSkills": ["ImageById"],
"subscriptionId": "Bing.Chat.Multimodal",
Expand Down Expand Up @@ -399,7 +399,7 @@ async def _ask(
return # Return empty message.

# Fix index in some cases where the last message in an inline message.
# Typically occurs when an attechment is provided.
# Typically occurs when an attachment is provided.
i = -1
adaptiveCards = messages[-1].get("adaptiveCards")
if adaptiveCards and adaptiveCards[-1]["body"][0].get("inlines"):
Expand Down

0 comments on commit 01f5985

Please sign in to comment.