Spaces:
Running
Running
Fix: bug that did not allow large amount of token in any model
Browse files- server/backend.py +9 -6
server/backend.py
CHANGED
@@ -183,16 +183,19 @@ def response_jailbroken_failed(response):
|
|
183 |
return False if len(response) < 4 else not (response.startswith("GPT:") or response.startswith("ACT:"))
|
184 |
|
185 |
|
186 |
-
def set_response_language(prompt):
|
187 |
"""
|
188 |
Set the response language based on the prompt content.
|
189 |
-
|
190 |
:param prompt: Prompt dictionary
|
191 |
:return: String indicating the language to be used for the response
|
192 |
-
"""
|
193 |
-
translator = Translator()
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
196 |
|
197 |
|
198 |
def getJailbreak(jailbreak):
|
|
|
183 |
return False if len(response) < 4 else not (response.startswith("GPT:") or response.startswith("ACT:"))
|
184 |
|
185 |
|
186 |
+
def set_response_language(prompt):
|
187 |
"""
|
188 |
Set the response language based on the prompt content.
|
189 |
+
|
190 |
:param prompt: Prompt dictionary
|
191 |
:return: String indicating the language to be used for the response
|
192 |
+
"""
|
193 |
+
translator = Translator()
|
194 |
+
max_chars = 256
|
195 |
+
content_sample = prompt['content'][:max_chars]
|
196 |
+
detected_language = translator.detect(content_sample).lang
|
197 |
+
return f"You will respond in the language: {detected_language}. "
|
198 |
+
|
199 |
|
200 |
|
201 |
def getJailbreak(jailbreak):
|