summaryrefslogtreecommitdiffstats
path: root/unfinished/bing
diff options
context:
space:
mode:
authort.me/xtekky <98614666+xtekky@users.noreply.github.com>2023-04-27 17:28:36 +0200
committerGitHub <noreply@github.com>2023-04-27 17:28:36 +0200
commitbbb4d69a933ff90e33e072ecba32519db7a22612 (patch)
tree6fec52831117ee43fe7141a153b7e123ff09d469 /unfinished/bing
parentMerge pull request #201 from DanielShemesh/patch-4 (diff)
parentReformat code using PyCharm (diff)
downloadgpt4free-bbb4d69a933ff90e33e072ecba32519db7a22612.tar
gpt4free-bbb4d69a933ff90e33e072ecba32519db7a22612.tar.gz
gpt4free-bbb4d69a933ff90e33e072ecba32519db7a22612.tar.bz2
gpt4free-bbb4d69a933ff90e33e072ecba32519db7a22612.tar.lz
gpt4free-bbb4d69a933ff90e33e072ecba32519db7a22612.tar.xz
gpt4free-bbb4d69a933ff90e33e072ecba32519db7a22612.tar.zst
gpt4free-bbb4d69a933ff90e33e072ecba32519db7a22612.zip
Diffstat (limited to 'unfinished/bing')
-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())