summaryrefslogtreecommitdiffstats
path: root/unfinished/bing
diff options
context:
space:
mode:
authorAymane Hrouch <jo.aymane@gmail.com>2023-04-27 16:43:59 +0200
committerAymane Hrouch <jo.aymane@gmail.com>2023-04-27 16:43:59 +0200
commitf1594cfddecf2bd47a25d54852834b392eaa4efd (patch)
tree6fec52831117ee43fe7141a153b7e123ff09d469 /unfinished/bing
parentMerge pull request #201 from DanielShemesh/patch-4 (diff)
downloadgpt4free-f1594cfddecf2bd47a25d54852834b392eaa4efd.tar
gpt4free-f1594cfddecf2bd47a25d54852834b392eaa4efd.tar.gz
gpt4free-f1594cfddecf2bd47a25d54852834b392eaa4efd.tar.bz2
gpt4free-f1594cfddecf2bd47a25d54852834b392eaa4efd.tar.lz
gpt4free-f1594cfddecf2bd47a25d54852834b392eaa4efd.tar.xz
gpt4free-f1594cfddecf2bd47a25d54852834b392eaa4efd.tar.zst
gpt4free-f1594cfddecf2bd47a25d54852834b392eaa4efd.zip
Diffstat (limited to '')
-rw-r--r--unfinished/bing/__ini__.py39
1 files changed, 19 insertions, 20 deletions
diff --git a/unfinished/bing/__ini__.py b/unfinished/bing/__ini__.py
index 508b1067..1e4fd149 100644
--- a/unfinished/bing/__ini__.py
+++ b/unfinished/bing/__ini__.py
@@ -1,14 +1,12 @@
# Import necessary libraries
-from requests import get
-from browser_cookie3 import edge, chrome
-from ssl import create_default_context
-from certifi import where
-from uuid import uuid4
-from random import randint
+import asyncio
from json import dumps, loads
+from ssl import create_default_context
-import asyncio
import websockets
+from browser_cookie3 import edge
+from certifi import where
+from requests import get
# Set up SSL context
ssl_context = create_default_context()
@@ -28,14 +26,14 @@ def get_token():
class AsyncCompletion:
async def create(
- prompt: str = 'hello world',
- optionSets: list = [
- 'deepleo',
- 'enable_debug_commands',
- 'disable_emoji_spoken_text',
- 'enablemm',
- 'h3relaxedimg'
- ],
+ prompt: str = 'hello world',
+ optionSets: list = [
+ 'deepleo',
+ 'enable_debug_commands',
+ 'disable_emoji_spoken_text',
+ 'enablemm',
+ 'h3relaxedimg'
+ ],
token: str = get_token()):
"""Create a connection to Bing AI and send the prompt."""
@@ -83,7 +81,7 @@ class AsyncCompletion:
continue
response = loads(obj)
- if response.get('type') == 1 and response['arguments'][0].get('messages',):
+ if response.get('type') == 1 and response['arguments'][0].get('messages', ):
response_text = response['arguments'][0]['messages'][0]['adaptiveCards'][0]['body'][0].get(
'text')
@@ -99,11 +97,12 @@ class AsyncCompletion:
async def run():
"""Run the async completion and print the result."""
async for value in AsyncCompletion.create(
- prompt='summarize cinderella with each word beginning with a consecutive letter of the alphabet, a-z',
- optionSets=[
- "galileo",
- ]
+ prompt='summarize cinderella with each word beginning with a consecutive letter of the alphabet, a-z',
+ optionSets=[
+ "galileo",
+ ]
):
print(value, end='', flush=True)
+
asyncio.run(run())