-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbardbot.py
More file actions
31 lines (26 loc) · 801 Bytes
/
bardbot.py
File metadata and controls
31 lines (26 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from os import environ
from Bard import Chatbot
import aiohttp,requests
from sydney import SydneyClient
from urllib.parse import quote
token = environ.get("BARD_TOKEN")
environ["BING_COOKIES"]=''
#environ.get("BARD_TOKEN")
def initBard(bard_token):
token = bard_token
async def bardChat(bard_msg):
chatbot = Chatbot(token)
bot_reply = chatbot.ask(bard_msg)
return bot_reply['content']
async def xbingChat(qtn_text):
async with SydneyClient() as sydney:
res_str = await sydney.ask(qtn_text)
return res_str
async def bingChat(qtn_text):
url_data = quote(qtn_text)
req_str = f"https://api.freegpt4.ddns.net/?text={url_data}"
print(req_str)
req = requests.get(req_str)
res_str = req.text
print(f"response is: {res_str}")
return res_str