forked from xtekky/gpt4free
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
168 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from requests import Session | ||
from time import sleep | ||
from json import loads | ||
from re import findall | ||
class Mail: | ||
def __init__(self) -> None: | ||
self.client = Session() | ||
self.client.post("https://etempmail.com/") | ||
self.cookies = {'acceptcookie': 'true'} | ||
self.cookies["ci_session"] = self.client.cookies.get_dict()["ci_session"] | ||
self.email = None | ||
def get_mail(self): | ||
respone=self.client.post("https://etempmail.com/getEmailAddress") | ||
#cookies | ||
self.cookies["lisansimo"] = eval(respone.text)["recover_key"] | ||
self.email = eval(respone.text)["address"] | ||
return self.email | ||
def get_message(self): | ||
print("Waiting for message...") | ||
while True: | ||
sleep(5) | ||
respone=self.client.post("https://etempmail.com/getInbox") | ||
mail_token=loads(respone.text) | ||
print(self.client.cookies.get_dict()) | ||
if len(mail_token) == 1: | ||
break | ||
|
||
params = {'id': '1',} | ||
self.mail_context = self.client.post("https://etempmail.com/getInbox",params=params) | ||
self.mail_context = eval(self.mail_context.text)[0]["body"] | ||
return self.mail_context | ||
#,cookies=self.cookies | ||
def get_verification_code(self): | ||
message = self.mail_context | ||
code = findall(r';">(\d{6,7})</div>', message)[0] | ||
print(f"Verification code: {code}") | ||
return code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import usesless | ||
|
||
question1 = "Who won the world series in 2020?" | ||
req = usesless.Completion.create(prompt=question1) | ||
answer = req["text"] | ||
message_id = req["parentMessageId"] | ||
|
||
question2 = "Where was it played?" | ||
req2 = usesless.Completion.create(prompt=question2, parentMessageId=message_id) | ||
answer2 = req2["text"] | ||
|
||
print(answer) | ||
print(answer2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
ai.usesless.com | ||
|
||
to do: | ||
|
||
- use random user agent in header | ||
- make the code better I guess (?) | ||
|
||
### Example: `usesless` <a name="example-usesless"></a> | ||
|
||
```python | ||
import usesless | ||
|
||
message_id = "" | ||
while True: | ||
prompt = input("Question: ") | ||
if prompt == "!stop": | ||
break | ||
|
||
req = usesless.Completion.create(prompt=prompt, parentMessageId=message_id) | ||
|
||
print(f"Answer: {req['text']}") | ||
message_id = req["id"] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import requests | ||
import json | ||
|
||
|
||
class Completion: | ||
headers = { | ||
"authority": "ai.usesless.com", | ||
"accept": "application/json, text/plain, */*", | ||
"accept-language": "en-US,en;q=0.5", | ||
"cache-control": "no-cache", | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin", | ||
"user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/112.0", | ||
} | ||
|
||
@staticmethod | ||
def create( | ||
systemMessage: str = "You are a helpful assistant", | ||
prompt: str = "", | ||
parentMessageId: str = "", | ||
presence_penalty: float = 1, | ||
temperature: float = 1, | ||
model: str = "gpt-3.5-turbo", | ||
): | ||
json_data = { | ||
"openaiKey": "", | ||
"prompt": prompt, | ||
"options": { | ||
"parentMessageId": parentMessageId, | ||
"systemMessage": systemMessage, | ||
"completionParams": { | ||
"presence_penalty": presence_penalty, | ||
"temperature": temperature, | ||
"model": model, | ||
}, | ||
}, | ||
} | ||
|
||
url = "https://ai.usesless.com/api/chat-process" | ||
request = requests.post(url, headers=Completion.headers, json=json_data) | ||
content = request.content | ||
response = Completion.__response_to_json(content) | ||
return response | ||
|
||
@classmethod | ||
def __response_to_json(cls, text) -> dict: | ||
text = str(text.decode("utf-8")) | ||
split_text = text.rsplit("\n", 1)[1] | ||
to_json = json.loads(split_text) | ||
return to_json |