From 2cca6a7cdd87f39468c4d462a2895cb79a77451a Mon Sep 17 00:00:00 2001 From: "benying1988@gmail.com" Date: Fri, 19 May 2023 17:00:27 +0800 Subject: feat: update readme to install ffmpeg and set proxy --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 98174965..1159ea98 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,32 @@ python3 -m venv venv pip3 install -r requirements.txt ``` +## Install ffmpeg +```sh +sudo apt-get install ffmpeg +``` + +## Connect VPN if needed and get proxy (Optional) +```sh +echo "$http_proxy" # http://127.0.0.1:8889/ +``` + +## Set proxy in gpt4free/you/__init__.py (Optional) +``` +diff --git a/gpt4free/you/__init__.py b/gpt4free/you/__init__.py +index 11847fb..59d1162 100644 +--- a/gpt4free/you/__init__.py ++++ b/gpt4free/you/__init__.py +@@ -38,6 +38,7 @@ class Completion: + if chat is None: + chat = [] + ++ proxy = '127.0.0.1:8889' + proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else {} + + client = Session(client_identifier='chrome_108') +``` + ## To start gpt4free GUI -- cgit v1.2.3 From 288fe0777f527a59264560f14cfe0796d37c0dbe Mon Sep 17 00:00:00 2001 From: xtekky <98614666+xtekky@users.noreply.github.com> Date: Fri, 19 May 2023 14:17:27 +0100 Subject: countdown timer --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1159ea98..bc3b5a50 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,9 @@ Please note the following: 3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations. -4. **Copyright**: All content in this repository, including but not limited to code, images, and documentation, is the intellectual property of the repository author, unless otherwise stated. Unauthorized copying, distribution, or use of any content in this repository is strictly prohibited without the express written consent of the repository author. +4. **Indemnification**: Users agree to indemnify, defend, and hold harmless the author of this repository from and against any and all claims, liabilities, damages, losses, or expenses, including legal fees and costs, arising out of or in any way connected with their use or misuse of this repository, its content, or related third-party APIs. -5. **Indemnification**: Users agree to indemnify, defend, and hold harmless the author of this repository from and against any and all claims, liabilities, damages, losses, or expenses, including legal fees and costs, arising out of or in any way connected with their use or misuse of this repository, its content, or related third-party APIs. - -6. **Updates and Changes**: The author reserves the right to modify, update, or remove any content, information, or features in this repository at any time without prior notice. Users are responsible for regularly reviewing the content and any changes made to this repository. +5. **Updates and Changes**: The author reserves the right to modify, update, or remove any content, information, or features in this repository at any time without prior notice. Users are responsible for regularly reviewing the content and any changes made to this repository. By using this repository or any code related to it, you agree to these terms. The author is not responsible for any copies, forks, or reuploads made by other users. This is the author's only account and repository. To prevent impersonation or irresponsible actions, you may comply with the GNU GPL license this Repository uses. -- cgit v1.2.3 From 053719847dc80a37007406c69bf7979c4ae697db Mon Sep 17 00:00:00 2001 From: Sife-shuo <88375951+Sife-shuo@users.noreply.github.com> Date: Fri, 19 May 2023 23:01:57 +0800 Subject: upload italtgpt2 --- gpt4free/italygpt2/README.md | 29 +++++++++++++++++ gpt4free/italygpt2/__init__.py | 70 ++++++++++++++++++++++++++++++++++++++++++ testing/italygpt2_test.py | 4 +++ 3 files changed, 103 insertions(+) create mode 100644 gpt4free/italygpt2/README.md create mode 100644 gpt4free/italygpt2/__init__.py create mode 100644 testing/italygpt2_test.py diff --git a/gpt4free/italygpt2/README.md b/gpt4free/italygpt2/README.md new file mode 100644 index 00000000..0845e89a --- /dev/null +++ b/gpt4free/italygpt2/README.md @@ -0,0 +1,29 @@ +# Itagpt2(Rewrite) +Written by [sife-shuo](https://github.com/sife-shuo/). + +## Description +Unlike gpt4free. italygpt in the pypi package, italygpt2 supports stream calls and has changed the request sending method to enable continuous and logical conversations. + +The speed will increase when calling the conversation multiple times. + +### Completion: +```python +account_data=italygpt2.Account.create() +for chunk in italygpt2.Completion.create(account_data=account_data,prompt="Who are you?"): + print(chunk, end="", flush=True) +print() +``` + +### Chat +Like most chatgpt projects, format is supported. +Use the same format for the messages as you would for the [official OpenAI API](https://platform.openai.com/docs/guides/chat/introduction). +```python +messages = [ + {"role": "system", "content": ""},#... + {"role": "user", "content": ""}#.... +] +account_data=italygpt2.Account.create() +for chunk in italygpt2.Completion.create(account_data=account_data,prompt="Who are you?",message=messages): + print(chunk, end="", flush=True) +print() +``` \ No newline at end of file diff --git a/gpt4free/italygpt2/__init__.py b/gpt4free/italygpt2/__init__.py new file mode 100644 index 00000000..1eb191c0 --- /dev/null +++ b/gpt4free/italygpt2/__init__.py @@ -0,0 +1,70 @@ +import re +import requests +import hashlib +from fake_useragent import UserAgent +class Account: + @staticmethod + def create(): + r=requests.get("https://italygpt.it/",headers=Account._header) + f=r.text + tid=re.search('',f).group(1) + if len(tid)==0: + raise RuntimeError("NetWorkError:failed to get id.") + else: + Account._tid=tid + Account._raw="[]" + return Account + def next(next_id:str)->str: + Account._tid=next_id + return Account._tid + def get()->str: + return Account._tid + _header={ + "Host": "italygpt.it", + "Referer":"https://italygpt.it/", + "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",#UserAgent().random, + "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", + "Accept-Language":"zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2", + "Upgrade-Insecure-Requests":"1", + "Sec-Fetch-Dest":"document", + "Sec-Fetch-Mode":"navigate", + "Sec-Fetch-Site":"none", + "Sec-Fetch-User":"?1", + "Connection":"keep-alive", + "Alt-Used":"italygpt.it", + "Pragma":"no-cache", + "Cache-Control":"no-cache", + "TE": "trailers" + } + def settraw(raws:str): + Account._raw=raws + return Account._raw + def gettraw(): + return Account._raw + +class Completion: + @staticmethod + def create( + account_data, + prompt: str, + message=False + ): + param={ + "prompt":prompt.replace(" ","+"), + "creative":"off", + "internet":"false", + "detailed":"off", + "current_id":"0", + "code":"", + "gpt4":"false", + "raw_messages":account_data.gettraw(), + "hash":hashlib.sha256(account_data.get().encode()).hexdigest() + } + if(message): + param["raw_messages"]=str(message) + r = requests.get("https://italygpt.it/question",headers=account_data._header,params=param,stream=True) + account_data.next(r.headers["Next_id"]) + account_data.settraw(r.headers["Raw_messages"]) + for chunk in r.iter_content(chunk_size=None): + r.raise_for_status() + yield chunk.decode() \ No newline at end of file diff --git a/testing/italygpt2_test.py b/testing/italygpt2_test.py new file mode 100644 index 00000000..0494c8a2 --- /dev/null +++ b/testing/italygpt2_test.py @@ -0,0 +1,4 @@ +from gpt4free import italygpt2 +account_data=italygpt2.Account.create() +for chunk in italygpt2.Completion.create(account_data=account_data,prompt="Who are you?"): + print(chunk, end="", flush=True) \ No newline at end of file -- cgit v1.2.3 From 74f949e0993958af6789dadc346f98a0ac27e345 Mon Sep 17 00:00:00 2001 From: ezerinz Date: Sat, 20 May 2023 21:44:01 +0800 Subject: add aiassist.site test --- testing/aiassistest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 testing/aiassistest.py diff --git a/testing/aiassistest.py b/testing/aiassistest.py new file mode 100644 index 00000000..57a34f15 --- /dev/null +++ b/testing/aiassistest.py @@ -0,0 +1,13 @@ +import aiassist + +question1 = "Who won the world series in 2020?" +req = aiassist.Completion.create(prompt=question1) +answer = req["text"] +message_id = req["parentMessageId"] + +question2 = "Where was it played?" +req2 = aiassist.Completion.create(prompt=question2, parentMessageId=message_id) +answer2 = req2["text"] + +print(answer) +print(answer2) -- cgit v1.2.3 From 8449728aa3fed6c91d0aac371145f83b90295bb2 Mon Sep 17 00:00:00 2001 From: ezerinz Date: Sat, 20 May 2023 21:45:05 +0800 Subject: add aiassist.site --- gpt4free/aiassist/README.md | 19 +++++++++++++++++++ gpt4free/aiassist/__init__.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 gpt4free/aiassist/README.md create mode 100644 gpt4free/aiassist/__init__.py diff --git a/gpt4free/aiassist/README.md b/gpt4free/aiassist/README.md new file mode 100644 index 00000000..02904865 --- /dev/null +++ b/gpt4free/aiassist/README.md @@ -0,0 +1,19 @@ +aiassist.site + +### Example: `aiassist` dict: + decode_content = str(content.decode("utf-8")) + split = decode_content.rsplit("\n", 1)[1] + to_json = json.loads(split) + return to_json -- cgit v1.2.3 From 3745cdcfd5cd27ef134535cc194b23c3b9b877a2 Mon Sep 17 00:00:00 2001 From: Edwin <100193740+ezerinz@users.noreply.github.com> Date: Sat, 20 May 2023 21:48:01 +0800 Subject: Update README.md --- gpt4free/aiassist/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpt4free/aiassist/README.md b/gpt4free/aiassist/README.md index 02904865..b6101784 100644 --- a/gpt4free/aiassist/README.md +++ b/gpt4free/aiassist/README.md @@ -1,6 +1,6 @@ aiassist.site -### Example: `aiassist` ```python import aiassist -- cgit v1.2.3 From 7f4322e1067bf2f6a8819014b7b21580406942a8 Mon Sep 17 00:00:00 2001 From: ezerinz Date: Sun, 21 May 2023 19:28:19 +0800 Subject: update usesless, add function to retrieve token --- gpt4free/usesless/README.md | 21 +++++-- gpt4free/usesless/__init__.py | 105 +++++++++++++++++++++++++++++----- gpt4free/usesless/account_creation.py | 3 + 3 files changed, 108 insertions(+), 21 deletions(-) create mode 100644 gpt4free/usesless/account_creation.py diff --git a/gpt4free/usesless/README.md b/gpt4free/usesless/README.md index 13e9df8c..afe6c9c7 100644 --- a/gpt4free/usesless/README.md +++ b/gpt4free/usesless/README.md @@ -1,23 +1,32 @@ ai.usesless.com -to do: +### Example: `usesless` -- use random user agent in header -- make the code better I guess (?) +### create account -### Example: `usesless` +

create account first, this will create account.txt that contains mail and token

+```python +import usesless + +usesless.Account.create(logging=True) + +```` + +### completion +

insert token from account.txt

```python import usesless message_id = "" +token = # usesless.Account.create(logging=True) while True: prompt = input("Question: ") if prompt == "!stop": break - req = usesless.Completion.create(prompt=prompt, parentMessageId=message_id) + req = usesless.Completion.create(prompt=prompt, parentMessageId=message_id, token=token) print(f"Answer: {req['text']}") message_id = req["id"] -``` +```` diff --git a/gpt4free/usesless/__init__.py b/gpt4free/usesless/__init__.py index 40e99938..7c61936e 100644 --- a/gpt4free/usesless/__init__.py +++ b/gpt4free/usesless/__init__.py @@ -1,22 +1,87 @@ +import time +import re import json - import requests +import fake_useragent +import names +from mailgw_temporary_email import Email +from password_generator import PasswordGenerator -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", - } +class Account: + @staticmethod + def create(logging: bool = False): + mail_client = Email() + mail_client.register() + mail_address = mail_client.address + + pwo = PasswordGenerator() + pwo.minlen = 8 + password = pwo.generate() + + session = requests.Session() + + if logging: + print(f"email: {mail_address}") + + register_url = "https://ai.usesless.com/api/cms/auth/local/register" + register_json = { + "username": names.get_first_name(), + "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("register success") + else: + print("there's a problem with account creation, try again") + + if register.status_code != 200: + quit() + + while True: + time.sleep(5) + message_id = mail_client.message_list()[0]["id"] + message = mail_client.message(message_id) + 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: + print(f"token: {token}") + + with open("accounts.txt", "w") as f: + f.write(f"{mail_address}\n") + f.write(f"{token}") + + return token + + +class Completion: @staticmethod def create( + token: str, systemMessage: str = "You are a helpful assistant", prompt: str = "", parentMessageId: str = "", @@ -24,7 +89,17 @@ class Completion: temperature: float = 1, model: str = "gpt-3.5-turbo", ): - print(parentMessageId, prompt) + 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": "", @@ -41,14 +116,14 @@ class Completion: } url = "https://ai.usesless.com/api/chat-process" - request = requests.post(url, headers=Completion.headers, json=json_data) + request = requests.post(url, headers=headers, json=json_data) content = request.content response = Completion.__response_to_json(content) return response @classmethod - def __response_to_json(cls, text) -> dict: + def __response_to_json(cls, text) -> str: text = str(text.decode("utf-8")) split_text = text.rsplit("\n", 1)[1] diff --git a/gpt4free/usesless/account_creation.py b/gpt4free/usesless/account_creation.py new file mode 100644 index 00000000..05819453 --- /dev/null +++ b/gpt4free/usesless/account_creation.py @@ -0,0 +1,3 @@ +import usesless + +usesless.Account.create(logging=True) -- cgit v1.2.3 From 2dc4900db7c528fc7c972c0c0522ab43b6487f3b Mon Sep 17 00:00:00 2001 From: ezerinz Date: Sun, 21 May 2023 19:34:28 +0800 Subject: Update readme --- gpt4free/usesless/README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gpt4free/usesless/README.md b/gpt4free/usesless/README.md index afe6c9c7..426314cb 100644 --- a/gpt4free/usesless/README.md +++ b/gpt4free/usesless/README.md @@ -2,15 +2,14 @@ ai.usesless.com ### Example: `usesless` -### create account +### token generation +

this will create account.txt that contains mail and token

-

create account first, this will create account.txt that contains mail and token

```python import usesless usesless.Account.create(logging=True) - -```` +``` ### completion

insert token from account.txt

@@ -29,4 +28,4 @@ while True: print(f"Answer: {req['text']}") message_id = req["id"] -```` +``` -- cgit v1.2.3