summaryrefslogtreecommitdiffstats
path: root/g4f/.v1/gpt4free/usesless
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/.v1/gpt4free/usesless')
-rw-r--r--g4f/.v1/gpt4free/usesless/README.md33
-rw-r--r--g4f/.v1/gpt4free/usesless/__init__.py158
-rw-r--r--g4f/.v1/gpt4free/usesless/account.json1
-rw-r--r--g4f/.v1/gpt4free/usesless/account_creation.py3
-rw-r--r--g4f/.v1/gpt4free/usesless/test.py10
-rw-r--r--g4f/.v1/gpt4free/usesless/utils/__init__.py139
6 files changed, 0 insertions, 344 deletions
diff --git a/g4f/.v1/gpt4free/usesless/README.md b/g4f/.v1/gpt4free/usesless/README.md
deleted file mode 100644
index 7b2ea169..00000000
--- a/g4f/.v1/gpt4free/usesless/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-ai.usesless.com
-
-### Example: `usesless` <a name="example-usesless"></a>
-
-### Token generation
-<p>This will create account.json that contains email and token in json</p>
-
-```python
-from gpt4free import usesless
-
-
-token = usesless.Account.create(logging=True)
-print(token)
-```
-
-### Completion
-<p>Insert token from account.json</p>
-
-```python
-import usesless
-
-message_id = ""
-token = <TOKENHERE> # usesless.Account.create(logging=True)
-while True:
- prompt = input("Question: ")
- if prompt == "!stop":
- break
-
- req = usesless.Completion.create(prompt=prompt, parentMessageId=message_id, token=token)
-
- print(f"Answer: {req['text']}")
- message_id = req["id"]
-```
diff --git a/g4f/.v1/gpt4free/usesless/__init__.py b/g4f/.v1/gpt4free/usesless/__init__.py
deleted file mode 100644
index 00f7f75d..00000000
--- a/g4f/.v1/gpt4free/usesless/__init__.py
+++ /dev/null
@@ -1,158 +0,0 @@
-import string
-import time
-import re
-import json
-import requests
-import fake_useragent
-import random
-from password_generator import PasswordGenerator
-
-from .utils import create_email, check_email
-
-
-class Account:
- @staticmethod
- def create(logging: bool = False):
- is_custom_domain = input(
- "Do you want to use your custom domain name for temporary email? [Y/n]: "
- ).upper()
-
- if is_custom_domain == "Y":
- mail_address = create_email(custom_domain=True, logging=logging)
- elif is_custom_domain == "N":
- mail_address = create_email(custom_domain=False, logging=logging)
- else:
- print("Please, enter either Y or N")
- return
-
- name = string.ascii_lowercase + string.digits
- username = "".join(random.choice(name) for i in range(20))
-
- pwo = PasswordGenerator()
- pwo.minlen = 8
- password = pwo.generate()
-
- session = requests.Session()
-
- register_url = "https://ai.usesless.com/api/cms/auth/local/register"
- register_json = {
- "username": username,
- "password": password,
- "email": mail_address,
- }
- 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": fake_useragent.UserAgent().random,
- }
- register = session.post(register_url, json=register_json, headers=headers)
- if logging:
- if register.status_code == 200:
- print("Registered successfully")
- else:
- print(register.status_code)
- print(register.json())
- print("There was a problem with account registration, try again")
-
- if register.status_code != 200:
- quit()
-
- while True:
- time.sleep(5)
- messages = check_email(mail=mail_address, logging=logging)
-
- # Check if method `message_list()` didn't return None or empty list.
- if not messages or len(messages) == 0:
- # If it returned None or empty list sleep for 5 seconds to wait for new message.
- continue
-
- message_text = messages[0]["content"]
- verification_url = re.findall(
- r"http:\/\/ai\.usesless\.com\/api\/cms\/auth\/email-confirmation\?confirmation=\w.+\w\w",
- message_text,
- )[0]
- if verification_url:
- break
-
- session.get(verification_url)
- login_json = {"identifier": mail_address, "password": password}
- login_request = session.post(
- url="https://ai.usesless.com/api/cms/auth/local", json=login_json
- )
-
- token = login_request.json()["jwt"]
- if logging and token:
- print(f"Token: {token}")
-
- with open("account.json", "w") as file:
- json.dump({"email": mail_address, "token": token}, file)
- if logging:
- print(
- "\nNew account credentials has been successfully saved in 'account.json' file"
- )
-
- return token
-
-
-class Completion:
- @staticmethod
- def create(
- token: str,
- systemMessage: str = "You are a helpful assistant",
- prompt: str = "",
- parentMessageId: str = "",
- presence_penalty: float = 1,
- temperature: float = 1,
- model: str = "gpt-3.5-turbo",
- ):
- 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": fake_useragent.UserAgent().random,
- "Authorization": f"Bearer {token}",
- }
-
- 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=headers, json=json_data)
- request.encoding = request.apparent_encoding
- content = request.content
-
- response = Completion.__response_to_json(content)
- return response
-
-
- @classmethod
- def __response_to_json(cls, text) -> str:
- text = str(text.decode("utf-8"))
-
- split_text = text.rsplit("\n", 1)
- if len(split_text) > 1:
- to_json = json.loads(split_text[1])
- return to_json
- else:
- return None
-
diff --git a/g4f/.v1/gpt4free/usesless/account.json b/g4f/.v1/gpt4free/usesless/account.json
deleted file mode 100644
index 53a210ac..00000000
--- a/g4f/.v1/gpt4free/usesless/account.json
+++ /dev/null
@@ -1 +0,0 @@
-{"email": "enganese-test-email@1secmail.net", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Mzg1MDEsImlhdCI6MTY4NTExMDgzOSwiZXhwIjoxNzE2NjY4NDM5fQ.jfEQOFWYQP2Xx4U-toorPg3nh31mxl3L0D2hRROmjZA"} \ No newline at end of file
diff --git a/g4f/.v1/gpt4free/usesless/account_creation.py b/g4f/.v1/gpt4free/usesless/account_creation.py
deleted file mode 100644
index 05819453..00000000
--- a/g4f/.v1/gpt4free/usesless/account_creation.py
+++ /dev/null
@@ -1,3 +0,0 @@
-import usesless
-
-usesless.Account.create(logging=True)
diff --git a/g4f/.v1/gpt4free/usesless/test.py b/g4f/.v1/gpt4free/usesless/test.py
deleted file mode 100644
index ade1e0c5..00000000
--- a/g4f/.v1/gpt4free/usesless/test.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# Fix by @enganese
-# Import Account class from __init__.py file
-from gpt4free import usesless
-
-# Create Account and enable logging to see all the log messages (it's very interesting, try it!)
-# New account credentials will be automatically saved in account.json file in such template: {"email": "username@1secmail.com", "token": "token here"}
-token = usesless.Account.create(logging=True)
-
-# Print the new token
-print(token)
diff --git a/g4f/.v1/gpt4free/usesless/utils/__init__.py b/g4f/.v1/gpt4free/usesless/utils/__init__.py
deleted file mode 100644
index 818c605d..00000000
--- a/g4f/.v1/gpt4free/usesless/utils/__init__.py
+++ /dev/null
@@ -1,139 +0,0 @@
-import requests
-import random
-import string
-import time
-import sys
-import re
-import os
-
-
-def check_email(mail, logging: bool = False):
- username = mail.split("@")[0]
- domain = mail.split("@")[1]
- reqLink = f"https://www.1secmail.com/api/v1/?action=getMessages&login={username}&domain={domain}"
- req = requests.get(reqLink)
- req.encoding = req.apparent_encoding
- req = req.json()
-
- length = len(req)
-
- if logging:
- os.system("cls" if os.name == "nt" else "clear")
- time.sleep(1)
- print("Your temporary mail:", mail)
-
- if logging and length == 0:
- print(
- "Mailbox is empty. Hold tight. Mailbox is refreshed automatically every 5 seconds.",
- )
- else:
- messages = []
- id_list = []
-
- for i in req:
- for k, v in i.items():
- if k == "id":
- id_list.append(v)
-
- x = "mails" if length > 1 else "mail"
-
- if logging:
- print(
- f"Mailbox has {length} {x}. (Mailbox is refreshed automatically every 5 seconds.)"
- )
-
- for i in id_list:
- msgRead = f"https://www.1secmail.com/api/v1/?action=readMessage&login={username}&domain={domain}&id={i}"
- req = requests.get(msgRead)
- req.encoding = req.apparent_encoding
- req = req.json()
-
- for k, v in req.items():
- if k == "from":
- sender = v
- if k == "subject":
- subject = v
- if k == "date":
- date = v
- if k == "textBody":
- content = v
-
- if logging:
- print(
- "Sender:",
- sender,
- "\nTo:",
- mail,
- "\nSubject:",
- subject,
- "\nDate:",
- date,
- "\nContent:",
- content,
- "\n",
- )
- messages.append(
- {
- "sender": sender,
- "to": mail,
- "subject": subject,
- "date": date,
- "content": content,
- }
- )
-
- if logging:
- os.system("cls" if os.name == "nt" else "clear")
- return messages
-
-
-def create_email(custom_domain: bool = False, logging: bool = False):
- domainList = ["1secmail.com", "1secmail.net", "1secmail.org"]
- domain = random.choice(domainList)
- try:
- if custom_domain:
- custom_domain = input(
- "\nIf you enter 'my-test-email' as your domain name, mail address will look like this: 'my-test-email@1secmail.com'"
- "\nEnter the name that you wish to use as your domain name: "
- )
-
- newMail = f"https://www.1secmail.com/api/v1/?login={custom_domain}&domain={domain}"
- reqMail = requests.get(newMail)
- reqMail.encoding = reqMail.apparent_encoding
-
- username = re.search(r"login=(.*)&", newMail).group(1)
- domain = re.search(r"domain=(.*)", newMail).group(1)
- mail = f"{username}@{domain}"
-
- if logging:
- print("\nYour temporary email was created successfully:", mail)
- return mail
-
- else:
- name = string.ascii_lowercase + string.digits
- random_username = "".join(random.choice(name) for i in range(10))
- newMail = f"https://www.1secmail.com/api/v1/?login={random_username}&domain={domain}"
-
- reqMail = requests.get(newMail)
- reqMail.encoding = reqMail.apparent_encoding
-
- username = re.search(r"login=(.*)&", newMail).group(1)
- domain = re.search(r"domain=(.*)", newMail).group(1)
- mail = f"{username}@{domain}"
-
- if logging:
- print("\nYour temporary email was created successfully:", mail)
- return mail
-
- except KeyboardInterrupt:
- requests.post(
- "https://www.1secmail.com/mailbox",
- data={
- "action": "deleteMailbox",
- "login": f"{username}",
- "domain": f"{domain}",
- },
- )
- if logging:
- print("\nKeyboard Interrupt Detected! \nTemporary mail was disposed!")
- os.system("cls" if os.name == "nt" else "clear")