summaryrefslogtreecommitdiffstats
path: root/g4f
diff options
context:
space:
mode:
Diffstat (limited to 'g4f')
-rw-r--r--g4f/Provider/Bing.py9
-rw-r--r--g4f/Provider/FakeGpt.py2
2 files changed, 8 insertions, 3 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):
diff --git a/g4f/Provider/FakeGpt.py b/g4f/Provider/FakeGpt.py
index 2720845f..a88f3682 100644
--- a/g4f/Provider/FakeGpt.py
+++ b/g4f/Provider/FakeGpt.py
@@ -36,7 +36,7 @@ class FakeGpt(AsyncGeneratorProvider):
async with session.get(f"{cls.url}/api/loads", params={"t": int(time.time())}, proxy=proxy) as response:
response.raise_for_status()
list = (await response.json())["loads"]
- token_ids = [t["token_id"] for t in list if t["count"] == 0]
+ token_ids = [t["token_id"] for t in list]
data = {
"token_key": random.choice(token_ids),
"session_password": get_random_string()