summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornullstreak <139914347+nullstreak@users.noreply.github.com>2023-12-19 21:44:56 +0100
committerGitHub <noreply@github.com>2023-12-19 21:44:56 +0100
commit53bc24114e26d1065becfedbe01c9c5a6831eb0f (patch)
tree15cc6ca0aed9248109035b6f7d0daea5b8eccb0f
parentMerge pull request #1365 from NiNiyas/fix-typo (diff)
downloadgpt4free-53bc24114e26d1065becfedbe01c9c5a6831eb0f.tar
gpt4free-53bc24114e26d1065becfedbe01c9c5a6831eb0f.tar.gz
gpt4free-53bc24114e26d1065becfedbe01c9c5a6831eb0f.tar.bz2
gpt4free-53bc24114e26d1065becfedbe01c9c5a6831eb0f.tar.lz
gpt4free-53bc24114e26d1065becfedbe01c9c5a6831eb0f.tar.xz
gpt4free-53bc24114e26d1065becfedbe01c9c5a6831eb0f.tar.zst
gpt4free-53bc24114e26d1065becfedbe01c9c5a6831eb0f.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/Bing.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py
index 56e964c0..f1255553 100644
--- a/g4f/Provider/Bing.py
+++ b/g4f/Provider/Bing.py
@@ -44,6 +44,7 @@ class Bing(AsyncGeneratorProvider):
cookies: dict = None,
tone: str = Tones.creative,
image: str = None,
+ web_search: bool = False,
**kwargs
) -> AsyncResult:
if len(messages) < 2:
@@ -59,7 +60,7 @@ class Bing(AsyncGeneratorProvider):
for key, value in default_cookies.items():
if key not in cookies:
cookies[key] = value
- return stream_generate(prompt, tone, image, context, proxy, cookies)
+ return stream_generate(prompt, tone, image, context, proxy, cookies, web_search)
def create_context(messages: Messages):
return "".join(
@@ -376,7 +377,7 @@ def compress_image_to_base64(img, compression_rate) -> str:
except Exception as e:
raise e
-def create_message(conversation: Conversation, prompt: str, tone: str, context: str=None) -> str:
+def create_message(conversation: Conversation, prompt: str, tone: str, context: str = None, web_search: bool = False) -> str:
options_sets = Defaults.optionsSets
if tone == Tones.creative:
options_sets.append("h3imaginative")
@@ -386,6 +387,8 @@ def create_message(conversation: Conversation, prompt: str, tone: str, context:
options_sets.append("galileo")
else:
options_sets.append("harmonyv3")
+ if not web_search:
+ options_sets.append("nosearchall")
request_id = str(uuid.uuid4())
struct = {
@@ -440,7 +443,8 @@ async def stream_generate(
image: str = None,
context: str = None,
proxy: str = None,
- cookies: dict = None
+ cookies: dict = None,
+ web_search: bool = False
):
async with ClientSession(
timeout=ClientTimeout(total=900),
@@ -452,7 +456,7 @@ async def stream_generate(
await wss.send_str(format_message({'protocol': 'json', 'version': 1}))
await wss.receive(timeout=900)
- await wss.send_str(create_message(conversation, prompt, tone, context))
+ await wss.send_str(create_message(conversation, prompt, tone, context, web_search))
response_txt = ''
returned_text = ''