mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-05 00:01:00 +00:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # docker-compose.yml # gpt4free/forefront/__init__.py
This commit is contained in:
commit
8bdd71fe6e
79
README.md
79
README.md
@ -1,22 +1,46 @@
|
||||
##### You may join our discord server for updates and support ; )
|
||||
|
||||
- [Discord Link](https://discord.gg/gpt4free)
|
||||
|
||||
<img width="1383" alt="image" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
|
||||
|
||||
<img alt="gpt4free logo" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
|
||||
<img src="https://media.giphy.com/media/LnQjpWaON8nhr21vNW/giphy.gif" width="100" align="left">
|
||||
Just API's from some language model sites.
|
||||
<p>Join our <a href="https://discord.com/invite/gpt4free">discord.gg/gpt4free<a> Discord community! <a href="https://discord.gg/gpt4free"><img align="center" alt="gpt4free Discord" width="22px" src="https://raw.githubusercontent.com/peterthehan/peterthehan/master/assets/discord.svg" /></a></p>
|
||||
|
||||
## Legal Notice <a name="legal-notice"></a>
|
||||
|
||||
This repository uses third-party APIs and is _not_ associated with or endorsed by the API providers. This project is intended **for educational purposes only**. This is just a little personal project. Sites may contact me to improve their security.
|
||||
# Related gpt4free projects
|
||||
|
||||
Please note the following:
|
||||
<table>
|
||||
<thead align="center">
|
||||
<tr border: none;>
|
||||
<td><b>🎁 Projects</b></td>
|
||||
<td><b>⭐ Stars</b></td>
|
||||
<td><b>📚 Forks</b></td>
|
||||
<td><b>🛎 Issues</b></td>
|
||||
<td><b>📬 Pull requests</b></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="https://github.com/xtekky/gpt4free"><b>gpt4free</b></a></td>
|
||||
<td><a href="https://github.com/xtekky/gpt4free/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
|
||||
<td><a href="https://github.com/xtekky/gpt4free/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
|
||||
<td><a href="https://github.com/xtekky/gpt4free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
|
||||
<td><a href="https://github.com/xtekky/gpt4free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xtekky/gpt4free?style=flat-square&labelColor=343b41"/></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://github.com/xtekky/chatgpt-clone"><b>ChatGPT-Clone</b></a></td>
|
||||
<td><a href="https://github.com/xtekky/chatgpt-clone/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
|
||||
<td><a href="https://github.com/xtekky/chatgpt-clone/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
|
||||
<td><a href="https://github.com/xtekky/chatgpt-clone/issues"><img alt="Issues" src="https://img.shields.io/github/issues/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
|
||||
<td><a href="https://github.com/xtekky/chatgpt-clone/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free"><b>ChatGpt Discord Bot</b></a></td>
|
||||
<td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/mishalhossin/Coding-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
|
||||
<td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/mishalhossin/Coding-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
|
||||
<td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/mishalhossin/Coding-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
|
||||
<td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/mishalhossin/Coding-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is _not_ claiming any right over them.
|
||||
|
||||
2. **Responsibility**: The author of this repository is _not_ responsible for any consequences arising from the use or misuse of this repository or the content provided by the third-party APIs and any damage or losses caused by users' actions.
|
||||
|
||||
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.
|
||||
|
||||
## Table of Contents
|
||||
| Section | Description | Link | Status |
|
||||
@ -28,9 +52,6 @@ Please note the following:
|
||||
| **Docker** | Instructions on how to run gpt4free in a Docker container | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#docker-instructions) | - |
|
||||
| **ChatGPT clone** | A ChatGPT clone with new features and scalability | [![Link to Website](https://img.shields.io/badge/Link-Visit%20Site-blue)](https://chat.chatbot.sex/chat) | - |
|
||||
| **How to install** | Instructions on how to install gpt4free | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#install) | - |
|
||||
| **Legal Notice** | Legal notice or disclaimer | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#legal-notice) | - |
|
||||
| **Copyright** | Copyright information | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#copyright) | - |
|
||||
| **Star History** | Star History | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#star-history) | - |
|
||||
| **Usage Examples** | | | |
|
||||
| `theb` | Example usage for theb (gpt-3.5) | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](gpt4free/theb/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) |
|
||||
| `forefront` | Example usage for forefront (gpt-4) | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](gpt4free/forefront/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) | ||
|
||||
@ -39,8 +60,12 @@ Please note the following:
|
||||
| **Try it Out** | | | |
|
||||
| Google Colab Jupyter Notebook | Example usage for gpt4free | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/DanielShemesh/gpt4free-colab/blob/main/gpt4free.ipynb) | - |
|
||||
| replit Example (feel free to fork this repl) | Example usage for gpt4free | [![](https://img.shields.io/badge/Open%20in-Replit-1A1E27?logo=replit)](https://replit.com/@gpt4free/gpt4free-webui) | - |
|
||||
| **Legal Notice** | Legal notice or disclaimer | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#legal-notice) | - |
|
||||
| **Copyright** | Copyright information | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#copyright) | - |
|
||||
| **Star History** | Star History | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#star-history) | - |
|
||||
|
||||
## Todo <a name="todo"></a>
|
||||
|
||||
## To do list <a name="todo"></a>
|
||||
|
||||
- [x] Add a GUI for the repo
|
||||
- [ ] Make a general package named `gpt4free`, instead of different folders
|
||||
@ -82,6 +107,7 @@ install requirements with:
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
|
||||
## To start gpt4free GUI <a name="streamlit-gpt4free-gui"></a>
|
||||
|
||||
Move `streamlit_app.py` from `./gui` to the base folder
|
||||
@ -121,6 +147,18 @@ docker-compose up -d
|
||||
> This site was developed by me and includes **gpt-4/3.5**, **internet access** and **gpt-jailbreak's** like DAN
|
||||
> run locally here: https://github.com/xtekky/chatgpt-clone
|
||||
|
||||
## Legal Notice <a name="legal-notice"></a>
|
||||
|
||||
This repository uses third-party APIs and is _not_ associated with or endorsed by the API providers. This project is intended **for educational purposes only**. This is just a little personal project. Sites may contact me to improve their security.
|
||||
|
||||
Please note the following:
|
||||
|
||||
1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is _not_ claiming any right over them.
|
||||
|
||||
2. **Responsibility**: The author of this repository is _not_ responsible for any consequences arising from the use or misuse of this repository or the content provided by the third-party APIs and any damage or losses caused by users' actions.
|
||||
|
||||
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.
|
||||
|
||||
## Copyright:
|
||||
|
||||
This program is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
@ -147,6 +185,9 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
```
|
||||
|
||||
|
||||
## Star History <a name="star-history"></a>
|
||||
|
||||
[![Star History Chart](https://api.star-history.com/svg?repos=xtekky/gpt4free&type=Date)](https://star-history.com/#xtekky/gpt4free)
|
||||
<a href="https://github.com/xtekky/gpt4free/stargazers">
|
||||
<img width="500" alt="Star History Chart" src="https://api.star-history.com/svg?repos=xtekky/gpt4free&type=Date">
|
||||
</a>
|
||||
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@ -0,0 +1,12 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
gpt4:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: gpt4free:latest
|
||||
container_name: gpt4
|
||||
ports:
|
||||
- 8501:8501
|
||||
restart: unless-stopped
|
@ -5,6 +5,7 @@ from gpt4free import forefront
|
||||
from gpt4free import quora
|
||||
from gpt4free import theb
|
||||
from gpt4free import you
|
||||
from gpt4free import usesless
|
||||
|
||||
|
||||
class Provider(Enum):
|
||||
@ -15,6 +16,7 @@ class Provider(Enum):
|
||||
ForeFront = 'fore_front'
|
||||
Theb = 'theb'
|
||||
CoCalc = 'cocalc'
|
||||
UseLess = 'useless'
|
||||
|
||||
|
||||
class Completion:
|
||||
@ -22,6 +24,7 @@ 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
|
||||
|
||||
@ -40,9 +43,15 @@ class Completion:
|
||||
return Completion.__theb_service(prompt, **kwargs)
|
||||
elif provider == Provider.CoCalc:
|
||||
return Completion.__cocalc_service(prompt, **kwargs)
|
||||
elif provider == Provider.UseLess:
|
||||
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)
|
||||
|
||||
@staticmethod
|
||||
def __you_service(prompt: str, **kwargs) -> str:
|
||||
return you.Completion.create(prompt, **kwargs).text
|
||||
|
@ -1,13 +1,10 @@
|
||||
### Example: `forefront` (use like openai pypi package) <a name="example-forefront"></a>
|
||||
|
||||
```python
|
||||
|
||||
from gpt4free import forefront
|
||||
|
||||
# create an account
|
||||
token = forefront.Account.create(logging=False)
|
||||
print(token)
|
||||
|
||||
# get a response
|
||||
for response in forefront.StreamingCompletion.create(token=token,
|
||||
prompt='hello world', model='gpt-4'):
|
||||
|
@ -1,59 +1,47 @@
|
||||
import re
|
||||
import time
|
||||
from json import loads
|
||||
from re import findall
|
||||
from time import time, sleep
|
||||
from typing import Generator, Optional
|
||||
from uuid import uuid4
|
||||
|
||||
import fake_useragent
|
||||
import pymailtm
|
||||
import requests
|
||||
from fake_useragent import UserAgent
|
||||
from requests import post
|
||||
from pymailtm import MailTm, Message
|
||||
from tls_client import Session
|
||||
|
||||
from .typing import ForeFrontResponse
|
||||
|
||||
|
||||
def speed_logging(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
start = time.time()
|
||||
res = func(*args, **kwargs)
|
||||
print(time() - start)
|
||||
return res
|
||||
return wrapper
|
||||
|
||||
|
||||
class Account:
|
||||
@speed_logging
|
||||
@staticmethod
|
||||
def create_forefront_account(proxy: Optional[str] = None) -> Optional[str]:
|
||||
"""Create a ForeFront account.
|
||||
def create(proxy: Optional[str] = None, logging: bool = False):
|
||||
proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
|
||||
|
||||
Args:
|
||||
proxy: The proxy to use for the request.
|
||||
start = time()
|
||||
|
||||
Returns:
|
||||
The ForeFront token if successful, else None.
|
||||
"""
|
||||
proxies = {'http': f'http://{proxy}', 'https': f'http://{proxy}'} if proxy else None
|
||||
|
||||
mail_client = pymailtm.MailTm().get_account()
|
||||
mail_client = MailTm().get_account()
|
||||
mail_address = mail_client.address
|
||||
|
||||
session = requests.Session()
|
||||
session.proxies = proxies
|
||||
session.headers = {
|
||||
client = Session(client_identifier='chrome110')
|
||||
client.proxies = proxies
|
||||
client.headers = {
|
||||
'origin': 'https://accounts.forefront.ai',
|
||||
'user-agent': fake_useragent.UserAgent().random,
|
||||
'user-agent': UserAgent().random,
|
||||
}
|
||||
|
||||
response = session.post(
|
||||
response = client.post(
|
||||
'https://clerk.forefront.ai/v1/client/sign_ups?_clerk_js_version=4.38.4',
|
||||
data={'email_address': mail_address},
|
||||
)
|
||||
|
||||
try:
|
||||
trace_token = response.json()['response']['id']
|
||||
if logging:
|
||||
print(trace_token)
|
||||
except KeyError:
|
||||
return None
|
||||
return 'Failed to create account!'
|
||||
|
||||
response = session.post(
|
||||
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',
|
||||
@ -61,26 +49,38 @@ class Account:
|
||||
},
|
||||
)
|
||||
|
||||
if logging:
|
||||
print(response.text)
|
||||
|
||||
if 'sign_up_attempt' not in response.text:
|
||||
return None
|
||||
return 'Failed to create account!'
|
||||
|
||||
while True:
|
||||
time.sleep(1)
|
||||
new_message = mail_client.wait_for_message()
|
||||
sleep(1)
|
||||
new_message: Message = mail_client.wait_for_message()
|
||||
if logging:
|
||||
print(new_message.data['id'])
|
||||
|
||||
verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', new_message.text)[0]
|
||||
|
||||
verification_url = re.findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', new_message.text)
|
||||
if verification_url:
|
||||
break
|
||||
|
||||
response = session.get(verification_url[0])
|
||||
if logging:
|
||||
print(verification_url)
|
||||
|
||||
response = session.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')
|
||||
response = client.get(verification_url)
|
||||
|
||||
response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')
|
||||
|
||||
token = response.json()['response']['sessions'][0]['last_active_token']['jwt']
|
||||
|
||||
with open('accounts.txt', 'a') as f:
|
||||
f.write(f'{mail_address}:{token}\n')
|
||||
|
||||
if logging:
|
||||
print(time() - start)
|
||||
|
||||
return token
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ class StreamingCompletion:
|
||||
if not chat_id:
|
||||
chat_id = str(uuid4())
|
||||
|
||||
proxies = { 'http': f'http://{proxy}', 'https': f'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',
|
||||
@ -192,5 +192,3 @@ class Completion:
|
||||
|
||||
return final_response
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
from typing import Any, List
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
|
@ -23,6 +23,8 @@ class Completion:
|
||||
temperature: float = 1,
|
||||
model: str = "gpt-3.5-turbo",
|
||||
):
|
||||
print(parentMessageId, prompt)
|
||||
|
||||
json_data = {
|
||||
"openaiKey": "",
|
||||
"prompt": prompt,
|
||||
@ -40,12 +42,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
|
@ -11,7 +11,6 @@ import pickle
|
||||
|
||||
conversations_file = "conversations.pkl"
|
||||
|
||||
|
||||
def load_conversations():
|
||||
try:
|
||||
with open(conversations_file, "rb") as f:
|
||||
|
27
testing/useless_test.py
Normal file
27
testing/useless_test.py
Normal file
@ -0,0 +1,27 @@
|
||||
from gpt4free 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"]
|
||||
|
||||
|
||||
import gpt4free
|
||||
|
||||
message_id = ""
|
||||
while True:
|
||||
prompt = input("Question: ")
|
||||
if prompt == "!stop":
|
||||
break
|
||||
|
||||
req = gpt4free.Completion.create(provider = gpt4free.Provider.UseLess,
|
||||
prompt=prompt, parentMessageId=message_id)
|
||||
|
||||
print(f"Answer: {req['text']}")
|
||||
message_id = req["id"]
|
@ -1,6 +1,12 @@
|
||||
import requests
|
||||
import json
|
||||
|
||||
from queue import Queue, Empty
|
||||
from threading import Thread
|
||||
from json import loads
|
||||
from re import findall
|
||||
|
||||
|
||||
class Completion:
|
||||
|
||||
def request(prompt: str):
|
||||
@ -53,7 +59,8 @@ class Completion:
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload).text
|
||||
response = requests.request(
|
||||
"POST", url, headers=headers, data=payload).text
|
||||
Completion.stream_completed = True
|
||||
return {'response': response}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user