diff options
author | Raju Komati <komatiraju032@gmail.com> | 2023-05-01 16:34:45 +0200 |
---|---|---|
committer | Raju Komati <komatiraju032@gmail.com> | 2023-05-01 16:34:45 +0200 |
commit | 05494ebbb1436db8028d1e6e8189c550dc9ddf03 (patch) | |
tree | 636c1cb8ff869b90b9e5e86c664cd113d92cbce7 | |
parent | updated quora readme (diff) | |
download | gpt4free-05494ebbb1436db8028d1e6e8189c550dc9ddf03.tar gpt4free-05494ebbb1436db8028d1e6e8189c550dc9ddf03.tar.gz gpt4free-05494ebbb1436db8028d1e6e8189c550dc9ddf03.tar.bz2 gpt4free-05494ebbb1436db8028d1e6e8189c550dc9ddf03.tar.lz gpt4free-05494ebbb1436db8028d1e6e8189c550dc9ddf03.tar.xz gpt4free-05494ebbb1436db8028d1e6e8189c550dc9ddf03.tar.zst gpt4free-05494ebbb1436db8028d1e6e8189c550dc9ddf03.zip |
Diffstat (limited to '')
-rw-r--r-- | gpt4free/__init__.py | 7 | ||||
-rw-r--r-- | gpt4free/forefront/__init__.py | 16 | ||||
-rw-r--r-- | gpt4free/forefront/typing.py | 3 | ||||
-rw-r--r-- | gpt4free/quora/backup-mail.py | 30 | ||||
-rw-r--r-- | gpt4free/theb/__init__.py | 4 | ||||
-rw-r--r-- | gpt4free/usesless/__init__.py | 9 | ||||
-rw-r--r-- | gpt4free/you/__init__.py | 4 | ||||
-rw-r--r-- | testing/theb_test.py | 2 | ||||
-rw-r--r-- | testing/useless_test.py | 6 |
9 files changed, 42 insertions, 39 deletions
diff --git a/gpt4free/__init__.py b/gpt4free/__init__.py index b4742b64..6df778e3 100644 --- a/gpt4free/__init__.py +++ b/gpt4free/__init__.py @@ -4,8 +4,8 @@ from gpt4free import cocalc from gpt4free import forefront from gpt4free import quora from gpt4free import theb -from gpt4free import you from gpt4free import usesless +from gpt4free import you class Provider(Enum): @@ -24,7 +24,6 @@ class Completion: @staticmethod def create(provider: Provider, prompt: str, **kwargs) -> str: - """ Invokes the given provider with given prompt and addition arguments and returns the string response @@ -47,10 +46,10 @@ class Completion: return Completion.__useless_service(prompt, **kwargs) else: raise Exception('Provider not exist, Please try again') - + @staticmethod def __useless_service(prompt: str, **kwargs) -> str: - return usesless.Completion.create(prompt = prompt, **kwargs) + return usesless.Completion.create(prompt=prompt, **kwargs) @staticmethod def __you_service(prompt: str, **kwargs) -> str: diff --git a/gpt4free/forefront/__init__.py b/gpt4free/forefront/__init__.py index 969b33b8..4d679a14 100644 --- a/gpt4free/forefront/__init__.py +++ b/gpt4free/forefront/__init__.py @@ -5,8 +5,8 @@ from typing import Generator, Optional from uuid import uuid4 from fake_useragent import UserAgent -from requests import post from pymailtm import MailTm, Message +from requests import post from tls_client import Session from .typing import ForeFrontResponse @@ -43,10 +43,7 @@ class Account: response = client.post( f'https://clerk.forefront.ai/v1/client/sign_ups/{trace_token}/prepare_verification?_clerk_js_version=4.38.4', - data={ - 'strategy': 'email_link', - 'redirect_url': 'https://accounts.forefront.ai/sign-up/verify' - }, + data={'strategy': 'email_link', 'redirect_url': 'https://accounts.forefront.ai/sign-up/verify'}, ) if logging: @@ -93,14 +90,14 @@ class StreamingCompletion: action_type='new', default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default model='gpt-4', - proxy=None + proxy=None, ) -> Generator[ForeFrontResponse, None, None]: if not token: raise Exception('Token is required!') if not chat_id: chat_id = str(uuid4()) - proxies = { 'http': 'http://' + proxy, 'https': 'http://' + proxy } if proxy else None + proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None headers = { 'authority': 'chat-server.tenant-forefront-default.knative.chi.coreweave.com', @@ -168,7 +165,7 @@ class Completion: action_type='new', default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default model='gpt-4', - proxy=None + proxy=None, ) -> ForeFrontResponse: text = '' final_response = None @@ -179,7 +176,7 @@ class Completion: action_type=action_type, default_persona=default_persona, model=model, - proxy=proxy + proxy=proxy, ): if response: final_response = response @@ -191,4 +188,3 @@ class Completion: raise Exception('Unable to get the response, Please try again') return final_response -
\ No newline at end of file diff --git a/gpt4free/forefront/typing.py b/gpt4free/forefront/typing.py index a9025419..23e90903 100644 --- a/gpt4free/forefront/typing.py +++ b/gpt4free/forefront/typing.py @@ -1,4 +1,5 @@ from typing import Any, List + from pydantic import BaseModel @@ -22,4 +23,4 @@ class ForeFrontResponse(BaseModel): model: str choices: List[Choice] usage: Usage - text: str
\ No newline at end of file + text: str diff --git a/gpt4free/quora/backup-mail.py b/gpt4free/quora/backup-mail.py index 0a2a5e94..25d526d7 100644 --- a/gpt4free/quora/backup-mail.py +++ b/gpt4free/quora/backup-mail.py @@ -1,7 +1,10 @@ -from requests import Session
-from time import sleep
from json import loads
from re import findall
+from time import sleep
+
+from requests import Session
+
+
class Mail:
def __init__(self) -> None:
self.client = Session()
@@ -9,29 +12,34 @@ class Mail: 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
+ 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)
+ 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)
+
+ 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
+
+ # ,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
\ No newline at end of file + return code
diff --git a/gpt4free/theb/__init__.py b/gpt4free/theb/__init__.py index 75a15068..c696387e 100644 --- a/gpt4free/theb/__init__.py +++ b/gpt4free/theb/__init__.py @@ -19,7 +19,7 @@ class Completion: stream_completed = False @staticmethod - def request(prompt: str, proxy: Optional[str]=None): + def request(prompt: str, proxy: Optional[str] = None): headers = { 'authority': 'chatbot.theb.ai', 'content-type': 'application/json', @@ -40,7 +40,7 @@ class Completion: Completion.stream_completed = True @staticmethod - def create(prompt: str, proxy: Optional[str]=None) -> Generator[str, None, None]: + def create(prompt: str, proxy: Optional[str] = None) -> Generator[str, None, None]: Thread(target=Completion.request, args=[prompt, proxy]).start() while not Completion.stream_completed or not Completion.message_queue.empty(): diff --git a/gpt4free/usesless/__init__.py b/gpt4free/usesless/__init__.py index 6029009d..40e99938 100644 --- a/gpt4free/usesless/__init__.py +++ b/gpt4free/usesless/__init__.py @@ -1,6 +1,7 @@ -import requests import json +import requests + class Completion: headers = { @@ -24,7 +25,7 @@ class Completion: model: str = "gpt-3.5-turbo", ): print(parentMessageId, prompt) - + json_data = { "openaiKey": "", "prompt": prompt, @@ -42,14 +43,14 @@ class Completion: 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 diff --git a/gpt4free/you/__init__.py b/gpt4free/you/__init__.py index d084a842..da22d05e 100644 --- a/gpt4free/you/__init__.py +++ b/gpt4free/you/__init__.py @@ -30,12 +30,12 @@ class Completion: include_links: bool = False, detailed: bool = False, debug: bool = False, - proxy: Optional[str] = None + proxy: Optional[str] = None, ) -> PoeResponse: if chat is None: chat = [] - proxies = { 'http': 'http://' + proxy, 'https': 'http://' + proxy } if proxy else {} + proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else {} client = Session(client_identifier='chrome_108') client.headers = Completion.__get_headers() diff --git a/testing/theb_test.py b/testing/theb_test.py index 0fd2ec8b..5fa80908 100644 --- a/testing/theb_test.py +++ b/testing/theb_test.py @@ -2,4 +2,4 @@ from gpt4free import theb for token in theb.Completion.create('hello world'): print(token, end='', flush=True) - print('asdsos')
\ No newline at end of file + print('asdsos') diff --git a/testing/useless_test.py b/testing/useless_test.py index 9b613aac..47c92386 100644 --- a/testing/useless_test.py +++ b/testing/useless_test.py @@ -11,7 +11,6 @@ while True: print(f"Answer: {req['text']}") message_id = req["id"] - import gpt4free message_id = "" @@ -20,8 +19,7 @@ while True: if prompt == "!stop": break - req = gpt4free.Completion.create(provider = gpt4free.Provider.UseLess, - prompt=prompt, parentMessageId=message_id) + req = gpt4free.Completion.create(provider=gpt4free.Provider.UseLess, prompt=prompt, parentMessageId=message_id) print(f"Answer: {req['text']}") - message_id = req["id"]
\ No newline at end of file + message_id = req["id"] |