-
Notifications
You must be signed in to change notification settings - Fork 6
/
godgpt.py
32 lines (23 loc) · 804 Bytes
/
godgpt.py
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
32
# Follow on https://t.me/unrealcoder
import requests
import secrets
import re
class GodGPT:
def __init__(self) -> None:
self.api_url = "https://gptgod.site/api/session/free/gpt3p5"
def generate_id(self, hex_id:int = 16, zfill:int = 32):
return {"id": secrets.token_hex(hex_id).zfill(zfill)}
def generate_text(self, prompt: str):
payload = {
**self.generate_id(),
"content": prompt
}
response = requests.get(self.api_url, params=payload)
convo = []
for data in response.iter_lines(chunk_size=None):
msg = re.findall(r'data:\s*"(.*)"', data.decode())
if msg:
convo.append(msg[0])
return "".join(convo)
bot = GodGPT()
print(bot.generate_text("how are you"))