diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-01-23 02:17:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 02:17:02 +0100 |
commit | 2a35052687e9026d90607c7db915e7c5b4e4018e (patch) | |
tree | c28dfef872f8dda791553fe1ae46418990d1c6b1 /g4f/Provider/bing/upload_image.py | |
parent | Merge pull request #1501 from eltociear/patch-5 (diff) | |
parent | Fix create copilot comment (diff) | |
download | gpt4free-2a35052687e9026d90607c7db915e7c5b4e4018e.tar gpt4free-2a35052687e9026d90607c7db915e7c5b4e4018e.tar.gz gpt4free-2a35052687e9026d90607c7db915e7c5b4e4018e.tar.bz2 gpt4free-2a35052687e9026d90607c7db915e7c5b4e4018e.tar.lz gpt4free-2a35052687e9026d90607c7db915e7c5b4e4018e.tar.xz gpt4free-2a35052687e9026d90607c7db915e7c5b4e4018e.tar.zst gpt4free-2a35052687e9026d90607c7db915e7c5b4e4018e.zip |
Diffstat (limited to 'g4f/Provider/bing/upload_image.py')
-rw-r--r-- | g4f/Provider/bing/upload_image.py | 36 |
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 + } } } |