t.me/xtekky
commited on
Commit
·
a485cfb
1
Parent(s):
fce0656
unfinished api's (help is welcome)
Browse files- unfinished/bard/README.md +2 -0
- {experimental → unfinished}/bard/__init__.py +0 -0
- {experimental → unfinished}/bard/typings.py +0 -0
- unfinished/bing/README.md +2 -0
- {experimental → unfinished}/bing/__ini__.py +0 -0
- unfinished/gptbz/README.md +4 -0
- unfinished/gptbz/__init__.py +31 -0
- unfinished/openai/README.md +2 -0
- {experimental → unfinished}/openai/__ini__.py +0 -0
- unfinished/openprompt/README.md +5 -0
- unfinished/openprompt/create.py +64 -0
- unfinished/openprompt/mail.py +109 -0
- unfinished/openprompt/main.py +37 -0
- unfinished/openprompt/test.py +7 -0
- unfinished/sqlchat/README.md +3 -0
- unfinished/sqlchat/__init__.py +29 -0
- unfinished/theb.ai/README.md +3 -0
- unfinished/theb.ai/__init__.py +57 -0
unfinished/bard/README.md
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
to do:
|
2 |
+
- code refractoring
|
{experimental → unfinished}/bard/__init__.py
RENAMED
File without changes
|
{experimental → unfinished}/bard/typings.py
RENAMED
File without changes
|
unfinished/bing/README.md
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
to do:
|
2 |
+
- code refractoring
|
{experimental → unfinished}/bing/__ini__.py
RENAMED
File without changes
|
unfinished/gptbz/README.md
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
https://chat.gpt.bz
|
2 |
+
|
3 |
+
to do:
|
4 |
+
- code refractoring
|
unfinished/gptbz/__init__.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import websockets
|
3 |
+
|
4 |
+
from json import dumps, loads
|
5 |
+
|
6 |
+
async def test():
|
7 |
+
async with websockets.connect('wss://chatgpt.func.icu/conversation+ws') as wss:
|
8 |
+
|
9 |
+
await wss.send(dumps(separators=(',', ':'), obj = {
|
10 |
+
'content_type':'text',
|
11 |
+
'engine':'chat-gpt',
|
12 |
+
'parts':['hello world'],
|
13 |
+
'options':{}
|
14 |
+
}
|
15 |
+
))
|
16 |
+
|
17 |
+
ended = None
|
18 |
+
|
19 |
+
while not ended:
|
20 |
+
try:
|
21 |
+
response = await wss.recv()
|
22 |
+
json_response = loads(response)
|
23 |
+
ended = json_response.get('eof')
|
24 |
+
|
25 |
+
if not ended:
|
26 |
+
print(json_response['content']['parts'][0])
|
27 |
+
|
28 |
+
except websockets.ConnectionClosed:
|
29 |
+
break
|
30 |
+
|
31 |
+
asyncio.run(test())
|
unfinished/openai/README.md
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
to do:
|
2 |
+
- code refractoring
|
{experimental → unfinished}/openai/__ini__.py
RENAMED
File without changes
|
unfinished/openprompt/README.md
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
https://openprompt.co/
|
2 |
+
|
3 |
+
to do:
|
4 |
+
- finish integrating email client
|
5 |
+
- code refractoring
|
unfinished/openprompt/create.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from requests import post, get
|
2 |
+
from json import dumps
|
3 |
+
#from mail import MailClient
|
4 |
+
from time import sleep
|
5 |
+
from re import findall
|
6 |
+
|
7 |
+
html = get('https://developermail.com/mail/')
|
8 |
+
print(html.cookies.get('mailboxId'))
|
9 |
+
email = findall(r'mailto:(.*)">', html.text)[0]
|
10 |
+
|
11 |
+
headers = {
|
12 |
+
'apikey': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InVzanNtdWZ1emRjcnJjZXVobnlqIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzgyODYyMzYsImV4cCI6MTk5Mzg2MjIzNn0.2MQ9Lkh-gPqQwV08inIgqozfbYm5jdYWtf-rn-wfQ7U',
|
13 |
+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
|
14 |
+
'x-client-info': '@supabase/[email protected]',
|
15 |
+
}
|
16 |
+
|
17 |
+
json_data = {
|
18 |
+
'email' : email,
|
19 |
+
'password': 'T4xyt4Yn6WWQ4NC',
|
20 |
+
'data' : {},
|
21 |
+
'gotrue_meta_security': {},
|
22 |
+
}
|
23 |
+
|
24 |
+
response = post('https://usjsmufuzdcrrceuhnyj.supabase.co/auth/v1/signup', headers=headers, json=json_data)
|
25 |
+
print(response.json())
|
26 |
+
|
27 |
+
# email_link = None
|
28 |
+
# while not email_link:
|
29 |
+
# sleep(1)
|
30 |
+
|
31 |
+
# mails = mailbox.getmails()
|
32 |
+
# print(mails)
|
33 |
+
|
34 |
+
|
35 |
+
quit()
|
36 |
+
|
37 |
+
url = input("Enter the url: ")
|
38 |
+
response = get(url, allow_redirects=False)
|
39 |
+
|
40 |
+
# https://openprompt.co/#access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjgyMjk0ODcxLCJzdWIiOiI4NWNkNTNiNC1lZTUwLTRiMDQtOGJhNS0wNTUyNjk4ODliZDIiLCJlbWFpbCI6ImNsc2J5emdqcGhiQGJ1Z2Zvby5jb20iLCJwaG9uZSI6IiIsImFwcF9tZXRhZGF0YSI6eyJwcm92aWRlciI6ImVtYWlsIiwicHJvdmlkZXJzIjpbImVtYWlsIl19LCJ1c2VyX21ldGFkYXRhIjp7fSwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJvdHAiLCJ0aW1lc3RhbXAiOjE2ODE2OTAwNzF9XSwic2Vzc2lvbl9pZCI6ImY4MTg1YTM5LTkxYzgtNGFmMy1iNzAxLTdhY2MwY2MwMGNlNSJ9.UvcTfpyIM1TdzM8ZV6UAPWfa0rgNq4AiqeD0INy6zV8&expires_in=604800&refresh_token=_Zp8uXIA2InTDKYgo8TCqA&token_type=bearer&type=signup
|
41 |
+
|
42 |
+
redirect = response.headers.get('location')
|
43 |
+
access_token = redirect.split('&')[0].split('=')[1]
|
44 |
+
refresh_token = redirect.split('&')[2].split('=')[1]
|
45 |
+
|
46 |
+
supabase_auth_token = dumps([access_token, refresh_token, None, None, None], separators=(',', ':'))
|
47 |
+
print(supabase_auth_token)
|
48 |
+
|
49 |
+
cookies = {
|
50 |
+
'supabase-auth-token': supabase_auth_token
|
51 |
+
}
|
52 |
+
|
53 |
+
json_data = {
|
54 |
+
'messages': [
|
55 |
+
{
|
56 |
+
'role': 'user',
|
57 |
+
'content': 'how do I reverse a string in python?'
|
58 |
+
}
|
59 |
+
]
|
60 |
+
}
|
61 |
+
|
62 |
+
response = post('https://openprompt.co/api/chat2', cookies=cookies, json=json_data, stream=True)
|
63 |
+
for chunk in response.iter_content(chunk_size=1024):
|
64 |
+
print(chunk)
|
unfinished/openprompt/mail.py
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import email
|
3 |
+
|
4 |
+
class MailClient:
|
5 |
+
|
6 |
+
def __init__(self):
|
7 |
+
self.username = None
|
8 |
+
self.token = None
|
9 |
+
self.raw = None
|
10 |
+
self.mailids = None
|
11 |
+
self.mails = None
|
12 |
+
self.mail = None
|
13 |
+
|
14 |
+
def create(self, force=False):
|
15 |
+
headers = {
|
16 |
+
'accept': 'application/json',
|
17 |
+
}
|
18 |
+
|
19 |
+
if self.username:
|
20 |
+
pass
|
21 |
+
else:
|
22 |
+
self.response = requests.put(
|
23 |
+
'https://www.developermail.com/api/v1/mailbox', headers=headers)
|
24 |
+
self.response = self.response.json()
|
25 |
+
self.username = self.response['result']['name']
|
26 |
+
self.token = self.response['result']['token']
|
27 |
+
|
28 |
+
return {'username': self.username, 'token': self.token}
|
29 |
+
|
30 |
+
def destroy(self):
|
31 |
+
headers = {
|
32 |
+
'accept': 'application/json',
|
33 |
+
'X-MailboxToken': self.token,
|
34 |
+
}
|
35 |
+
self.response = requests.delete(
|
36 |
+
f'https://www.developermail.com/api/v1/mailbox/{self.username}', headers=headers)
|
37 |
+
self.response = self.response.json()
|
38 |
+
self.username = None
|
39 |
+
self.token = None
|
40 |
+
return self.response
|
41 |
+
|
42 |
+
def newtoken(self):
|
43 |
+
headers = {
|
44 |
+
'accept': 'application/json',
|
45 |
+
'X-MailboxToken': self.token,
|
46 |
+
}
|
47 |
+
self.response = requests.put(
|
48 |
+
f'https://www.developermail.com/api/v1/mailbox/{self.username}/token', headers=headers)
|
49 |
+
self.response = self.response.json()
|
50 |
+
self.token = self.response['result']['token']
|
51 |
+
return {'username': self.username, 'token': self.token}
|
52 |
+
|
53 |
+
def getmailids(self):
|
54 |
+
headers = {
|
55 |
+
'accept': 'application/json',
|
56 |
+
'X-MailboxToken': self.token,
|
57 |
+
}
|
58 |
+
|
59 |
+
self.response = requests.get(
|
60 |
+
f'https://www.developermail.com/api/v1/mailbox/{self.username}', headers=headers)
|
61 |
+
self.response = self.response.json()
|
62 |
+
self.mailids = self.response['result']
|
63 |
+
return self.mailids
|
64 |
+
|
65 |
+
def getmails(self, mailids: list = None):
|
66 |
+
headers = {
|
67 |
+
'accept': 'application/json',
|
68 |
+
'X-MailboxToken': self.token,
|
69 |
+
'Content-Type': 'application/json',
|
70 |
+
}
|
71 |
+
|
72 |
+
if mailids is None:
|
73 |
+
mailids = self.mailids
|
74 |
+
|
75 |
+
data = str(mailids)
|
76 |
+
|
77 |
+
self.response = requests.post(
|
78 |
+
f'https://www.developermail.com/api/v1/mailbox/{self.username}/messages', headers=headers, data=data)
|
79 |
+
self.response = self.response.json()
|
80 |
+
self.mails = self.response['result']
|
81 |
+
return self.mails
|
82 |
+
|
83 |
+
def getmail(self, mailid: str, raw=False):
|
84 |
+
headers = {
|
85 |
+
'accept': 'application/json',
|
86 |
+
'X-MailboxToken': self.token,
|
87 |
+
}
|
88 |
+
self.response = requests.get(
|
89 |
+
f'https://www.developermail.com/api/v1/mailbox/{self.username}/messages/{mailid}', headers=headers)
|
90 |
+
self.response = self.response.json()
|
91 |
+
self.mail = self.response['result']
|
92 |
+
if raw is False:
|
93 |
+
self.mail = email.message_from_string(self.mail)
|
94 |
+
return self.mail
|
95 |
+
|
96 |
+
def delmail(self, mailid: str):
|
97 |
+
headers = {
|
98 |
+
'accept': 'application/json',
|
99 |
+
'X-MailboxToken': self.token,
|
100 |
+
}
|
101 |
+
self.response = requests.delete(
|
102 |
+
f'https://www.developermail.com/api/v1/mailbox/{self.username}/messages/{mailid}', headers=headers)
|
103 |
+
self.response = self.response.json()
|
104 |
+
return self.response
|
105 |
+
|
106 |
+
|
107 |
+
client = MailClient()
|
108 |
+
client.newtoken()
|
109 |
+
print(client.getmails())
|
unfinished/openprompt/main.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
cookies = {
|
4 |
+
'supabase-auth-token': '["eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjgyMjk1NzQyLCJzdWIiOiJlOGExOTdiNS03YTAxLTQ3MmEtODQ5My1mNGUzNTNjMzIwNWUiLCJlbWFpbCI6InFlY3RncHZhamlibGNjQGJ1Z2Zvby5jb20iLCJwaG9uZSI6IiIsImFwcF9tZXRhZGF0YSI6eyJwcm92aWRlciI6ImVtYWlsIiwicHJvdmlkZXJzIjpbImVtYWlsIl19LCJ1c2VyX21ldGFkYXRhIjp7fSwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJvdHAiLCJ0aW1lc3RhbXAiOjE2ODE2OTA5NDJ9XSwic2Vzc2lvbl9pZCI6IjIwNTg5MmE5LWU5YTAtNDk2Yi1hN2FjLWEyMWVkMTkwZDA4NCJ9.o7UgHpiJMfa6W-UKCSCnAncIfeOeiHz-51sBmokg0MA","RtPKeb7KMMC9Dn2fZOfiHA",null,null,null]',
|
5 |
+
}
|
6 |
+
|
7 |
+
headers = {
|
8 |
+
'authority': 'openprompt.co',
|
9 |
+
'accept': '*/*',
|
10 |
+
'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
|
11 |
+
'content-type': 'application/json',
|
12 |
+
# 'cookie': 'supabase-auth-token=%5B%22eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjgyMjkzMjQ4LCJzdWIiOiJlODQwNTZkNC0xZWJhLTQwZDktOWU1Mi1jMTc4MTUwN2VmNzgiLCJlbWFpbCI6InNia2didGJnZHB2bHB0ZUBidWdmb28uY29tIiwicGhvbmUiOiIiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJlbWFpbCIsInByb3ZpZGVycyI6WyJlbWFpbCJdfSwidXNlcl9tZXRhZGF0YSI6e30sInJvbGUiOiJhdXRoZW50aWNhdGVkIiwiYWFsIjoiYWFsMSIsImFtciI6W3sibWV0aG9kIjoib3RwIiwidGltZXN0YW1wIjoxNjgxNjg4NDQ4fV0sInNlc3Npb25faWQiOiJiNDhlMmU3NS04NzlhLTQxZmEtYjQ4MS01OWY0OTgxMzg3YWQifQ.5-3E7WvMMVkXewD1qA26Rv4OFSTT82wYUBXNGcYaYfQ%22%2C%22u5TGGMMeT3zZA0agm5HGuA%22%2Cnull%2Cnull%2Cnull%5D',
|
13 |
+
'origin': 'https://openprompt.co',
|
14 |
+
'referer': 'https://openprompt.co/ChatGPT',
|
15 |
+
'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
|
16 |
+
'sec-ch-ua-mobile': '?0',
|
17 |
+
'sec-ch-ua-platform': '"macOS"',
|
18 |
+
'sec-fetch-dest': 'empty',
|
19 |
+
'sec-fetch-mode': 'cors',
|
20 |
+
'sec-fetch-site': 'same-origin',
|
21 |
+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
|
22 |
+
}
|
23 |
+
|
24 |
+
json_data = {
|
25 |
+
'messages': [
|
26 |
+
{
|
27 |
+
'role': 'user',
|
28 |
+
'content': 'hello world',
|
29 |
+
},
|
30 |
+
],
|
31 |
+
}
|
32 |
+
|
33 |
+
response = requests.post('https://openprompt.co/api/chat2', cookies=cookies, headers=headers, json=json_data, stream=True)
|
34 |
+
for chunk in response.iter_content(chunk_size=1024):
|
35 |
+
print(chunk)
|
36 |
+
|
37 |
+
|
unfinished/openprompt/test.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
access_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjgyMjk0ODcxLCJzdWIiOiI4NWNkNTNiNC1lZTUwLTRiMDQtOGJhNS0wNTUyNjk4ODliZDIiLCJlbWFpbCI6ImNsc2J5emdqcGhiQGJ1Z2Zvby5jb20iLCJwaG9uZSI6IiIsImFwcF9tZXRhZGF0YSI6eyJwcm92aWRlciI6ImVtYWlsIiwicHJvdmlkZXJzIjpbImVtYWlsIl19LCJ1c2VyX21ldGFkYXRhIjp7fSwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJvdHAiLCJ0aW1lc3RhbXAiOjE2ODE2OTAwNzF9XSwic2Vzc2lvbl9pZCI6ImY4MTg1YTM5LTkxYzgtNGFmMy1iNzAxLTdhY2MwY2MwMGNlNSJ9.UvcTfpyIM1TdzM8ZV6UAPWfa0rgNq4AiqeD0INy6zV'
|
2 |
+
supabase_auth_token= '%5B%22eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjgyMjk0ODcxLCJzdWIiOiI4NWNkNTNiNC1lZTUwLTRiMDQtOGJhNS0wNTUyNjk4ODliZDIiLCJlbWFpbCI6ImNsc2J5emdqcGhiQGJ1Z2Zvby5jb20iLCJwaG9uZSI6IiIsImFwcF9tZXRhZGF0YSI6eyJwcm92aWRlciI6ImVtYWlsIiwicHJvdmlkZXJzIjpbImVtYWlsIl19LCJ1c2VyX21ldGFkYXRhIjp7fSwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJvdHAiLCJ0aW1lc3RhbXAiOjE2ODE2OTAwNzF9XSwic2Vzc2lvbl9pZCI6ImY4MTg1YTM5LTkxYzgtNGFmMy1iNzAxLTdhY2MwY2MwMGNlNSJ9.UvcTfpyIM1TdzM8ZV6UAPWfa0rgNq4AiqeD0INy6zV8%22%2C%22_Zp8uXIA2InTDKYgo8TCqA%22%2Cnull%2Cnull%2Cnull%5D'
|
3 |
+
|
4 |
+
|
5 |
+
idk = [
|
6 |
+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjgyMjk0ODcxLCJzdWIiOiI4NWNkNTNiNC1lZTUwLTRiMDQtOGJhNS0wNTUyNjk4ODliZDIiLCJlbWFpbCI6ImNsc2J5emdqcGhiQGJ1Z2Zvby5jb20iLCJwaG9uZSI6IiIsImFwcF9tZXRhZGF0YSI6eyJwcm92aWRlciI6ImVtYWlsIiwicHJvdmlkZXJzIjpbImVtYWlsIl19LCJ1c2VyX21ldGFkYXRhIjp7fSwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJvdHAiLCJ0aW1lc3RhbXAiOjE2ODE2OTAwNzF9XSwic2Vzc2lvbl9pZCI6ImY4MTg1YTM5LTkxYzgtNGFmMy1iNzAxLTdhY2MwY2MwMGNlNSJ9.UvcTfpyIM1TdzM8ZV6UAPWfa0rgNq4AiqeD0INy6zV8",
|
7 |
+
"_Zp8uXIA2InTDKYgo8TCqA",None,None,None]
|
unfinished/sqlchat/README.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
https://www.sqlchat.ai/
|
2 |
+
to do:
|
3 |
+
- code refractoring
|
unfinished/sqlchat/__init__.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
headers = {
|
4 |
+
'authority': 'www.sqlchat.ai',
|
5 |
+
'accept': '*/*',
|
6 |
+
'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
|
7 |
+
'content-type': 'text/plain;charset=UTF-8',
|
8 |
+
'origin': 'https://www.sqlchat.ai',
|
9 |
+
'referer': 'https://www.sqlchat.ai/',
|
10 |
+
'sec-fetch-dest': 'empty',
|
11 |
+
'sec-fetch-mode': 'cors',
|
12 |
+
'sec-fetch-site': 'same-origin',
|
13 |
+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
|
14 |
+
}
|
15 |
+
|
16 |
+
data = {
|
17 |
+
'messages':[
|
18 |
+
{'role':'system','content':''},
|
19 |
+
{'role':'user','content':'hello world'},
|
20 |
+
],
|
21 |
+
'openAIApiConfig':{
|
22 |
+
'key':'',
|
23 |
+
'endpoint':''
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
response = requests.post('https://www.sqlchat.ai/api/chat', headers=headers, json=data, stream=True)
|
28 |
+
for message in response.iter_content(chunk_size=1024):
|
29 |
+
print(message)
|
unfinished/theb.ai/README.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
https://chatbot.theb.ai/
|
2 |
+
to do:
|
3 |
+
- code refractoring
|
unfinished/theb.ai/__init__.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from curl_cffi import requests
|
2 |
+
from json import loads
|
3 |
+
from re import findall
|
4 |
+
from threading import Thread
|
5 |
+
from queue import Queue, Empty
|
6 |
+
|
7 |
+
class Completion:
|
8 |
+
# experimental
|
9 |
+
part1 = '{"role":"assistant","id":"chatcmpl'
|
10 |
+
part2 = '"},"index":0,"finish_reason":null}]}}'
|
11 |
+
regex = rf'{part1}(.*){part2}'
|
12 |
+
|
13 |
+
timer = None
|
14 |
+
message_queue = Queue()
|
15 |
+
stream_completed = False
|
16 |
+
|
17 |
+
def request():
|
18 |
+
headers = {
|
19 |
+
'authority' : 'chatbot.theb.ai',
|
20 |
+
'content-type': 'application/json',
|
21 |
+
'origin' : 'https://chatbot.theb.ai',
|
22 |
+
'user-agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
|
23 |
+
}
|
24 |
+
|
25 |
+
requests.post('https://chatbot.theb.ai/api/chat-process', headers=headers, content_callback=Completion.handle_stream_response,
|
26 |
+
json = {
|
27 |
+
'prompt' : 'hello world',
|
28 |
+
'options': {}
|
29 |
+
}
|
30 |
+
)
|
31 |
+
|
32 |
+
Completion.stream_completed = True
|
33 |
+
|
34 |
+
@staticmethod
|
35 |
+
def create():
|
36 |
+
Thread(target=Completion.request).start()
|
37 |
+
|
38 |
+
while Completion.stream_completed != True or not Completion.message_queue.empty():
|
39 |
+
try:
|
40 |
+
message = Completion.message_queue.get(timeout=0.01)
|
41 |
+
for message in findall(Completion.regex, message):
|
42 |
+
yield loads(Completion.part1 + message + Completion.part2)
|
43 |
+
|
44 |
+
except Empty:
|
45 |
+
pass
|
46 |
+
|
47 |
+
@staticmethod
|
48 |
+
def handle_stream_response(response):
|
49 |
+
Completion.message_queue.put(response.decode())
|
50 |
+
|
51 |
+
def start():
|
52 |
+
for message in Completion.create():
|
53 |
+
yield message['delta']
|
54 |
+
|
55 |
+
if __name__ == '__main__':
|
56 |
+
for message in start():
|
57 |
+
print(message)
|