summaryrefslogtreecommitdiffstats
path: root/g4f/Provider
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2023-12-19 21:41:02 +0100
committerGitHub <noreply@github.com>2023-12-19 21:41:02 +0100
commita95c2423d93c764002fbae44c29806ac5f2facef (patch)
tree40a559ddb5bad1bbe2146183f6e14e33bdc16d49 /g4f/Provider
parentMerge pull request #1366 from devAdityaa/main (diff)
parentFix Bing provider Cookie issue 2 (diff)
downloadgpt4free-a95c2423d93c764002fbae44c29806ac5f2facef.tar
gpt4free-a95c2423d93c764002fbae44c29806ac5f2facef.tar.gz
gpt4free-a95c2423d93c764002fbae44c29806ac5f2facef.tar.bz2
gpt4free-a95c2423d93c764002fbae44c29806ac5f2facef.tar.lz
gpt4free-a95c2423d93c764002fbae44c29806ac5f2facef.tar.xz
gpt4free-a95c2423d93c764002fbae44c29806ac5f2facef.tar.zst
gpt4free-a95c2423d93c764002fbae44c29806ac5f2facef.zip
Diffstat (limited to 'g4f/Provider')
-rw-r--r--g4f/Provider/Bing.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py
index af6c5132..56e964c0 100644
--- a/g4f/Provider/Bing.py
+++ b/g4f/Provider/Bing.py
@@ -10,6 +10,7 @@ import base64
import numpy as np
import uuid
import urllib.parse
+import time
from PIL import Image
from aiohttp import ClientSession, ClientTimeout
from ..typing import AsyncResult, Messages
@@ -26,7 +27,7 @@ default_cookies = {
'KievRPSSecAuth': '',
'SUID' : '',
'SRCHUSR' : '',
- 'SRCHHPGUSR' : '',
+ 'SRCHHPGUSR' : f'HV={int(time.time())}',
}
class Bing(AsyncGeneratorProvider):
@@ -52,8 +53,12 @@ class Bing(AsyncGeneratorProvider):
prompt = messages[-1]["content"]
context = create_context(messages[:-1])
- if not cookies or "SRCHD" not in cookies:
+ if not cookies:
cookies = default_cookies
+ else:
+ for key, value in default_cookies.items():
+ if key not in cookies:
+ cookies[key] = value
return stream_generate(prompt, tone, image, context, proxy, cookies)
def create_context(messages: Messages):