summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/bing
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-23 01:47:55 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-23 01:47:55 +0100
commit07c944ad0a90e10e9401d34a626bbc7878ffab2a (patch)
tree05207374083d6e751cd84107259f5bd1e4d1e971 /g4f/Provider/bing
parentImprove CreateImagesBing (diff)
downloadgpt4free-07c944ad0a90e10e9401d34a626bbc7878ffab2a.tar
gpt4free-07c944ad0a90e10e9401d34a626bbc7878ffab2a.tar.gz
gpt4free-07c944ad0a90e10e9401d34a626bbc7878ffab2a.tar.bz2
gpt4free-07c944ad0a90e10e9401d34a626bbc7878ffab2a.tar.lz
gpt4free-07c944ad0a90e10e9401d34a626bbc7878ffab2a.tar.xz
gpt4free-07c944ad0a90e10e9401d34a626bbc7878ffab2a.tar.zst
gpt4free-07c944ad0a90e10e9401d34a626bbc7878ffab2a.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/bing/upload_image.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/g4f/Provider/bing/upload_image.py b/g4f/Provider/bing/upload_image.py
index 4d70659f..bb5687a8 100644
--- a/g4f/Provider/bing/upload_image.py
+++ b/g4f/Provider/bing/upload_image.py
@@ -82,13 +82,16 @@ def build_image_upload_payload(image_bin: str, tone: str) -> Tuple[str, str]:
Tuple[str, str]: The data and boundary for the payload.
"""
boundary = "----WebKitFormBoundary" + ''.join(random.choices(string.ascii_letters + string.digits, k=16))
- data = f"--{boundary}\r\n" \
- f"Content-Disposition: form-data; name=\"knowledgeRequest\"\r\n\r\n" \
- f"{json.dumps(build_knowledge_request(tone), ensure_ascii=False)}\r\n" \
- f"--{boundary}\r\n" \
- f"Content-Disposition: form-data; name=\"imageBase64\"\r\n\r\n" \
- f"{image_bin}\r\n" \
- f"--{boundary}--\r\n"
+ data = f"""--{boundary}
+Content-Disposition: form-data; name="knowledgeRequest"
+
+{json.dumps(build_knowledge_request(tone), ensure_ascii=False)}
+--{boundary}
+Content-Disposition: form-data; name="imageBase64"
+
+{image_bin}
+--{boundary}--
+"""
return data, boundary
def build_knowledge_request(tone: str) -> dict:
@@ -102,14 +105,17 @@ def build_knowledge_request(tone: str) -> dict:
dict: The knowledge request payload.
"""
return {
- 'invokedSkills': ["ImageById"],
- 'subscriptionId': "Bing.Chat.Multimodal",
- 'invokedSkillsRequestData': {
- 'enableFaceBlur': True
- },
- 'convoData': {
- 'convoid': "",
- 'convotone': tone
+ "imageInfo": {},
+ "knowledgeRequest": {
+ 'invokedSkills': ["ImageById"],
+ 'subscriptionId': "Bing.Chat.Multimodal",
+ 'invokedSkillsRequestData': {
+ 'enableFaceBlur': True
+ },
+ 'convoData': {
+ 'convoid': "",
+ 'convotone': tone
+ }
}
}