Spaces:
Paused
Paused
Merge branch 'main' into main
Browse files- README.md +8 -20
- client/.DS_Store +0 -0
- config.json +1 -2
- g4f/models.py +4 -4
- server/auto_proxy.py +0 -103
- server/backend.py +17 -24
README.md
CHANGED
|
@@ -7,9 +7,14 @@ This project features a WebUI utilizing the [G4F API](https://github.com/xtekky/
|
|
| 7 |
Experience the power of ChatGPT with a user-friendly interface, enhanced jailbreaks, and completely free.
|
| 8 |
|
| 9 |
## Known bugs 🚧
|
| 10 |
-
-
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
## Note ℹ️
|
| 15 |
<p>
|
|
@@ -28,8 +33,6 @@ Please note that the choice and integration of additional Providers are the user
|
|
| 28 |
- [Cloning the Repository](#cloning-the-repository-inbox_tray)
|
| 29 |
- [Install Dependencies](#install-dependencies-wrench)
|
| 30 |
- [Running the Application](#running-the-application-rocket)
|
| 31 |
-
- [Auto Proxy](#auto-proxy-)
|
| 32 |
-
- [Enable Auto Proxy](#enable-auto-proxy)
|
| 33 |
- [Docker](#docker-)
|
| 34 |
- [Prerequisites](#prerequisites)
|
| 35 |
- [Running the Docker](#running-the-docker)
|
|
@@ -49,9 +52,8 @@ Please note that the choice and integration of additional Providers are the user
|
|
| 49 |
- [x] Add the GPT-4 model
|
| 50 |
- [x] Enhance the user interface
|
| 51 |
- [ ] Check status of API Providers (online/offline)
|
| 52 |
-
- [ ] Auto Proxy
|
| 53 |
- [ ] Enable editing and creating Jailbreaks/Roles in the WebUI
|
| 54 |
-
- [ ]
|
| 55 |
|
| 56 |
## Getting Started :white_check_mark:
|
| 57 |
To get started with this project, you'll need to clone the repository and have [Python](https://www.python.org/downloads/) installed on your system.
|
|
@@ -87,20 +89,6 @@ or
|
|
| 87 |
```
|
| 88 |
http://localhost:1338
|
| 89 |
```
|
| 90 |
-
## Auto Proxy 🔑
|
| 91 |
-
The application includes an auto proxy feature that allows it to work with multiple free proxy servers.
|
| 92 |
-
The freeGPT API refuses some connections, especially when hosted in the cloud (Azure, AWS, Google Cloud).
|
| 93 |
-
Auto proxy solves this problem automatically for you.
|
| 94 |
-
When enabled, the application will automatically fetch and test proxy servers, updating the list of working proxies every 30 minutes.
|
| 95 |
-
|
| 96 |
-
### Enable Auto Proxy
|
| 97 |
-
To enable it, just go to the `config.json` file and change the value of the "use_auto_proxy" to `true`.
|
| 98 |
-
|
| 99 |
-
```
|
| 100 |
-
"use_auto_proxy": true
|
| 101 |
-
```
|
| 102 |
-

|
| 103 |
-
|
| 104 |
|
| 105 |
|
| 106 |
## Docker 🐳
|
|
|
|
| 7 |
Experience the power of ChatGPT with a user-friendly interface, enhanced jailbreaks, and completely free.
|
| 8 |
|
| 9 |
## Known bugs 🚧
|
| 10 |
+
- GPT-4 model offline.
|
| 11 |
|
| 12 |
+
## News 📢
|
| 13 |
+
I have created a new version of FreeGPT WebUI using the [ChimeraGPT API](https://chimeragpt.adventblocks.cc/).
|
| 14 |
+
<br>
|
| 15 |
+
<br>
|
| 16 |
+
This free API allows you to use various AI chat models, including <strong>GPT-4, GPT-4-32k, Claude-2, Claude-2-100k, and more.</strong> <br>
|
| 17 |
+
Check out the project here: [FreeGPT WebUI - Chimera Version](https://github.com/ramonvc/freegpt-webui/tree/chimeragpt-version).
|
| 18 |
|
| 19 |
## Note ℹ️
|
| 20 |
<p>
|
|
|
|
| 33 |
- [Cloning the Repository](#cloning-the-repository-inbox_tray)
|
| 34 |
- [Install Dependencies](#install-dependencies-wrench)
|
| 35 |
- [Running the Application](#running-the-application-rocket)
|
|
|
|
|
|
|
| 36 |
- [Docker](#docker-)
|
| 37 |
- [Prerequisites](#prerequisites)
|
| 38 |
- [Running the Docker](#running-the-docker)
|
|
|
|
| 52 |
- [x] Add the GPT-4 model
|
| 53 |
- [x] Enhance the user interface
|
| 54 |
- [ ] Check status of API Providers (online/offline)
|
|
|
|
| 55 |
- [ ] Enable editing and creating Jailbreaks/Roles in the WebUI
|
| 56 |
+
- [ ] Refactor web client
|
| 57 |
|
| 58 |
## Getting Started :white_check_mark:
|
| 59 |
To get started with this project, you'll need to clone the repository and have [Python](https://www.python.org/downloads/) installed on your system.
|
|
|
|
| 89 |
```
|
| 90 |
http://localhost:1338
|
| 91 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
|
| 94 |
## Docker 🐳
|
client/.DS_Store
DELETED
|
Binary file (6.15 kB)
|
|
|
config.json
CHANGED
|
@@ -4,6 +4,5 @@
|
|
| 4 |
"port": 1338,
|
| 5 |
"debug": false
|
| 6 |
},
|
| 7 |
-
"url_prefix": ""
|
| 8 |
-
"use_auto_proxy": false
|
| 9 |
}
|
|
|
|
| 4 |
"port": 1338,
|
| 5 |
"debug": false
|
| 6 |
},
|
| 7 |
+
"url_prefix": ""
|
|
|
|
| 8 |
}
|
g4f/models.py
CHANGED
|
@@ -10,22 +10,22 @@ class Model:
|
|
| 10 |
class gpt_35_turbo:
|
| 11 |
name: str = 'gpt-3.5-turbo'
|
| 12 |
base_provider: str = 'openai'
|
| 13 |
-
best_provider: Provider.Provider = random.choice([Provider.DeepAi, Provider.
|
| 14 |
|
| 15 |
class gpt_35_turbo_0613:
|
| 16 |
name: str = 'gpt-3.5-turbo-0613'
|
| 17 |
base_provider: str = 'openai'
|
| 18 |
-
best_provider: Provider.Provider = Provider.Gravityengine
|
| 19 |
|
| 20 |
class gpt_35_turbo_16k_0613:
|
| 21 |
name: str = 'gpt-3.5-turbo-16k-0613'
|
| 22 |
base_provider: str = 'openai'
|
| 23 |
-
best_provider: Provider.Provider = Provider.Gravityengine
|
| 24 |
|
| 25 |
class gpt_35_turbo_16k:
|
| 26 |
name: str = 'gpt-3.5-turbo-16k'
|
| 27 |
base_provider: str = 'openai'
|
| 28 |
-
best_provider: Provider.Provider = Provider.Gravityengine
|
| 29 |
|
| 30 |
class gpt_4_dev:
|
| 31 |
name: str = 'gpt-4-for-dev'
|
|
|
|
| 10 |
class gpt_35_turbo:
|
| 11 |
name: str = 'gpt-3.5-turbo'
|
| 12 |
base_provider: str = 'openai'
|
| 13 |
+
best_provider: Provider.Provider = random.choice([Provider.DeepAi, Provider.Easychat])
|
| 14 |
|
| 15 |
class gpt_35_turbo_0613:
|
| 16 |
name: str = 'gpt-3.5-turbo-0613'
|
| 17 |
base_provider: str = 'openai'
|
| 18 |
+
best_provider: Provider.Provider = random.choice([Provider.Gravityengine, Provider.Easychat])
|
| 19 |
|
| 20 |
class gpt_35_turbo_16k_0613:
|
| 21 |
name: str = 'gpt-3.5-turbo-16k-0613'
|
| 22 |
base_provider: str = 'openai'
|
| 23 |
+
best_provider: Provider.Provider = random.choice([Provider.Gravityengine, Provider.Easychat])
|
| 24 |
|
| 25 |
class gpt_35_turbo_16k:
|
| 26 |
name: str = 'gpt-3.5-turbo-16k'
|
| 27 |
base_provider: str = 'openai'
|
| 28 |
+
best_provider: Provider.Provider = random.choice([Provider.Gravityengine, Provider.Easychat])
|
| 29 |
|
| 30 |
class gpt_4_dev:
|
| 31 |
name: str = 'gpt-4-for-dev'
|
server/auto_proxy.py
DELETED
|
@@ -1,103 +0,0 @@
|
|
| 1 |
-
import random
|
| 2 |
-
import requests
|
| 3 |
-
import time
|
| 4 |
-
import threading
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
def fetch_proxies():
|
| 8 |
-
"""Fetch a list of proxy servers from proxyscrape.com.
|
| 9 |
-
|
| 10 |
-
Returns:
|
| 11 |
-
list: A list of proxy servers in the format "IP:Port".
|
| 12 |
-
"""
|
| 13 |
-
url = "https://api.proxyscrape.com/v2/?request=displayproxies&protocol=http&timeout=10000&country=all&ssl=all&anonymity=all"
|
| 14 |
-
response = requests.get(url)
|
| 15 |
-
if response.status_code == 200:
|
| 16 |
-
return response.text.split("\r\n")[:-1]
|
| 17 |
-
print(f"Error fetching proxies: {response.status_code}")
|
| 18 |
-
return []
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
def test_proxy(proxy, prompt, timeout):
|
| 22 |
-
"""Test the given proxy server with a specified prompt and timeout.
|
| 23 |
-
|
| 24 |
-
Args:
|
| 25 |
-
proxy (str): The proxy server in the format "IP:Port".
|
| 26 |
-
prompt (str): The test prompt to be used for testing.
|
| 27 |
-
timeout (int): The maximum time in seconds allowed for the test.
|
| 28 |
-
"""
|
| 29 |
-
try:
|
| 30 |
-
start_time = time.time()
|
| 31 |
-
# res = gpt3.Completion.create(prompt=prompt, proxy=proxy)
|
| 32 |
-
end_time = time.time()
|
| 33 |
-
response_time = end_time - start_time
|
| 34 |
-
|
| 35 |
-
if response_time < timeout:
|
| 36 |
-
response_time = int(response_time*1000)
|
| 37 |
-
print(f'proxy: {proxy} [{response_time}ms] ✅')
|
| 38 |
-
add_working_proxy((proxy))
|
| 39 |
-
except Exception as e:
|
| 40 |
-
pass
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
def add_working_proxy(proxy):
|
| 44 |
-
"""Add a working proxy server to the global working_proxies list.
|
| 45 |
-
|
| 46 |
-
Args:
|
| 47 |
-
proxy (str): The proxy server in the format "IP:Port".
|
| 48 |
-
"""
|
| 49 |
-
global working_proxies
|
| 50 |
-
working_proxies.append(proxy)
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
def remove_proxy(proxy):
|
| 54 |
-
"""Remove a proxy server from the global working_proxies list.
|
| 55 |
-
|
| 56 |
-
Args:
|
| 57 |
-
proxy (str): The proxy server in the format "IP:Port".
|
| 58 |
-
"""
|
| 59 |
-
global working_proxies
|
| 60 |
-
if proxy in working_proxies:
|
| 61 |
-
working_proxies.remove(proxy)
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
def get_working_proxies(prompt, timeout=5):
|
| 65 |
-
"""Fetch and test proxy servers, adding working proxies to the global working_proxies list.
|
| 66 |
-
|
| 67 |
-
Args:
|
| 68 |
-
prompt (str): The test prompt to be used for testing.
|
| 69 |
-
timeout (int, optional): The maximum time in seconds allowed for testing. Defaults to 5.
|
| 70 |
-
"""
|
| 71 |
-
proxy_list = fetch_proxies()
|
| 72 |
-
threads = []
|
| 73 |
-
|
| 74 |
-
for proxy in proxy_list:
|
| 75 |
-
thread = threading.Thread(target=test_proxy, args=(
|
| 76 |
-
proxy, prompt, timeout))
|
| 77 |
-
threads.append(thread)
|
| 78 |
-
thread.start()
|
| 79 |
-
|
| 80 |
-
for t in threads:
|
| 81 |
-
t.join(timeout)
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
def update_working_proxies():
|
| 85 |
-
"""Continuously update the global working_proxies list with working proxy servers."""
|
| 86 |
-
global working_proxies
|
| 87 |
-
test_prompt = "What is the capital of France?"
|
| 88 |
-
|
| 89 |
-
while True:
|
| 90 |
-
working_proxies = [] # Clear the list before updating
|
| 91 |
-
get_working_proxies(test_prompt)
|
| 92 |
-
print('proxies updated')
|
| 93 |
-
time.sleep(1800) # Update proxies list every 30 minutes
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
def get_random_proxy():
|
| 97 |
-
"""Get a random working proxy server from the global working_proxies list.
|
| 98 |
-
|
| 99 |
-
Returns:
|
| 100 |
-
str: A random working proxy server in the format "IP:Port".
|
| 101 |
-
"""
|
| 102 |
-
global working_proxies
|
| 103 |
-
return random.choice(working_proxies)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server/backend.py
CHANGED
|
@@ -6,7 +6,6 @@ from googletrans import Translator
|
|
| 6 |
from flask import request, Response, stream_with_context
|
| 7 |
from datetime import datetime
|
| 8 |
from requests import get
|
| 9 |
-
from server.auto_proxy import get_random_proxy, update_working_proxies
|
| 10 |
from server.config import special_instructions
|
| 11 |
|
| 12 |
|
|
@@ -14,24 +13,17 @@ class Backend_Api:
|
|
| 14 |
def __init__(self, bp, config: dict) -> None:
|
| 15 |
"""
|
| 16 |
Initialize the Backend_Api class.
|
| 17 |
-
|
| 18 |
:param app: Flask application instance
|
| 19 |
:param config: Configuration dictionary
|
| 20 |
"""
|
| 21 |
self.bp = bp
|
| 22 |
-
self.use_auto_proxy = config['use_auto_proxy']
|
| 23 |
self.routes = {
|
| 24 |
'/backend-api/v2/conversation': {
|
| 25 |
'function': self._conversation,
|
| 26 |
'methods': ['POST']
|
| 27 |
}
|
| 28 |
}
|
| 29 |
-
|
| 30 |
-
# if self.use_auto_proxy:
|
| 31 |
-
# update_proxies = threading.Thread(
|
| 32 |
-
# target=update_working_proxies, daemon=True)
|
| 33 |
-
# update_proxies.start()
|
| 34 |
-
|
| 35 |
def _conversation(self):
|
| 36 |
"""
|
| 37 |
Handles the conversation route.
|
|
@@ -181,11 +173,11 @@ def response_jailbroken_failed(response):
|
|
| 181 |
|
| 182 |
|
| 183 |
def set_response_language(prompt):
|
| 184 |
-
"""
|
| 185 |
-
Set the response language based on the prompt content.
|
| 186 |
|
| 187 |
-
:param prompt: Prompt dictionary
|
| 188 |
-
:return: String indicating the language to be used for the response
|
| 189 |
"""
|
| 190 |
translator = Translator()
|
| 191 |
max_chars = 256
|
|
@@ -194,18 +186,19 @@ def set_response_language(prompt):
|
|
| 194 |
return f"You will respond in the language: {detected_language}. "
|
| 195 |
|
| 196 |
|
| 197 |
-
|
| 198 |
def getJailbreak(jailbreak):
|
| 199 |
-
"""
|
| 200 |
-
Check if jailbreak instructions are provided.
|
| 201 |
|
| 202 |
-
:param jailbreak: Jailbreak instruction string
|
| 203 |
-
:return: Jailbreak instructions if provided, otherwise None
|
| 204 |
"""
|
| 205 |
-
if jailbreak
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
return None
|
| 210 |
-
special_instructions[jailbreak]
|
| 211 |
-
return special_instructions[jailbreak]
|
|
|
|
| 6 |
from flask import request, Response, stream_with_context
|
| 7 |
from datetime import datetime
|
| 8 |
from requests import get
|
|
|
|
| 9 |
from server.config import special_instructions
|
| 10 |
|
| 11 |
|
|
|
|
| 13 |
def __init__(self, bp, config: dict) -> None:
|
| 14 |
"""
|
| 15 |
Initialize the Backend_Api class.
|
|
|
|
| 16 |
:param app: Flask application instance
|
| 17 |
:param config: Configuration dictionary
|
| 18 |
"""
|
| 19 |
self.bp = bp
|
|
|
|
| 20 |
self.routes = {
|
| 21 |
'/backend-api/v2/conversation': {
|
| 22 |
'function': self._conversation,
|
| 23 |
'methods': ['POST']
|
| 24 |
}
|
| 25 |
}
|
| 26 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
def _conversation(self):
|
| 28 |
"""
|
| 29 |
Handles the conversation route.
|
|
|
|
| 173 |
|
| 174 |
|
| 175 |
def set_response_language(prompt):
|
| 176 |
+
"""
|
| 177 |
+
Set the response language based on the prompt content.
|
| 178 |
|
| 179 |
+
:param prompt: Prompt dictionary
|
| 180 |
+
:return: String indicating the language to be used for the response
|
| 181 |
"""
|
| 182 |
translator = Translator()
|
| 183 |
max_chars = 256
|
|
|
|
| 186 |
return f"You will respond in the language: {detected_language}. "
|
| 187 |
|
| 188 |
|
|
|
|
| 189 |
def getJailbreak(jailbreak):
|
| 190 |
+
"""
|
| 191 |
+
Check if jailbreak instructions are provided.
|
| 192 |
|
| 193 |
+
:param jailbreak: Jailbreak instruction string
|
| 194 |
+
:return: Jailbreak instructions if provided, otherwise None
|
| 195 |
"""
|
| 196 |
+
if jailbreak != "default":
|
| 197 |
+
special_instructions[jailbreak][0]['content'] += special_instructions['two_responses_instruction']
|
| 198 |
+
if jailbreak in special_instructions:
|
| 199 |
+
special_instructions[jailbreak]
|
| 200 |
+
return special_instructions[jailbreak]
|
| 201 |
+
else:
|
| 202 |
+
return None
|
| 203 |
+
else:
|
| 204 |
return None
|
|
|
|
|
|