Spaces:
Running
Running
Remove system message
Browse files- requirements.txt +0 -1
- server/backend.py +2 -30
requirements.txt
CHANGED
@@ -23,4 +23,3 @@ numpy>=1.22.2 # pinned to avoid a vulnerability
|
|
23 |
tornado>=6.3.2 # pinned to avoid a vulnerability
|
24 |
PyExecJS
|
25 |
browser_cookie3
|
26 |
-
googletrans==4.0.0rc1
|
|
|
23 |
tornado>=6.3.2 # pinned to avoid a vulnerability
|
24 |
PyExecJS
|
25 |
browser_cookie3
|
|
server/backend.py
CHANGED
@@ -2,9 +2,7 @@ import re
|
|
2 |
import time
|
3 |
import g4f
|
4 |
from g4f import ChatCompletion
|
5 |
-
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.config import special_instructions
|
10 |
|
@@ -23,7 +21,7 @@ class Backend_Api:
|
|
23 |
'methods': ['POST']
|
24 |
}
|
25 |
}
|
26 |
-
|
27 |
def _conversation(self):
|
28 |
"""
|
29 |
Handles the conversation route.
|
@@ -75,20 +73,8 @@ def build_messages(jailbreak):
|
|
75 |
internet_access = request.json['meta']['content']['internet_access']
|
76 |
prompt = request.json['meta']['content']['parts'][0]
|
77 |
|
78 |
-
# Generate system message
|
79 |
-
current_date = datetime.now().strftime("%Y-%m-%d")
|
80 |
-
system_message = (
|
81 |
-
f'You are ChatGPT also known as ChatGPT, a large language model trained by OpenAI. '
|
82 |
-
f'Strictly follow the users instructions. '
|
83 |
-
f'Knowledge cutoff: 2021-09-01 Current date: {current_date}. '
|
84 |
-
f'{set_response_language(prompt)}'
|
85 |
-
)
|
86 |
-
|
87 |
-
# Initialize the conversation with the system message
|
88 |
-
conversation = [{'role': 'system', 'content': system_message}]
|
89 |
-
|
90 |
# Add the existing conversation
|
91 |
-
conversation
|
92 |
|
93 |
# Add web results if enabled
|
94 |
conversation += fetch_search_results(
|
@@ -172,20 +158,6 @@ def response_jailbroken_failed(response):
|
|
172 |
return False if len(response) < 4 else not (response.startswith("GPT:") or response.startswith("ACT:"))
|
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
|
184 |
-
content_sample = prompt['content'][:max_chars]
|
185 |
-
detected_language = translator.detect(content_sample).lang
|
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.
|
|
|
2 |
import time
|
3 |
import g4f
|
4 |
from g4f import ChatCompletion
|
|
|
5 |
from flask import request, Response, stream_with_context
|
|
|
6 |
from requests import get
|
7 |
from server.config import special_instructions
|
8 |
|
|
|
21 |
'methods': ['POST']
|
22 |
}
|
23 |
}
|
24 |
+
|
25 |
def _conversation(self):
|
26 |
"""
|
27 |
Handles the conversation route.
|
|
|
73 |
internet_access = request.json['meta']['content']['internet_access']
|
74 |
prompt = request.json['meta']['content']['parts'][0]
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
# Add the existing conversation
|
77 |
+
conversation = _conversation
|
78 |
|
79 |
# Add web results if enabled
|
80 |
conversation += fetch_search_results(
|
|
|
158 |
return False if len(response) < 4 else not (response.startswith("GPT:") or response.startswith("ACT:"))
|
159 |
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
def getJailbreak(jailbreak):
|
162 |
"""
|
163 |
Check if jailbreak instructions are provided.
|