monra commited on
Commit
0efc2d5
1 Parent(s): 5da6e9b

Fix: jailbreak failed. Try again.

Browse files
Files changed (1) hide show
  1. server/backend.py +9 -8
server/backend.py CHANGED
@@ -134,16 +134,17 @@ def generate_stream(response, jailbreak):
134
  """
135
  if isJailbreak(jailbreak):
136
  response_jailbreak = ''
137
- unlocked = False
138
  for message in response:
139
  response_jailbreak += message
140
- if unlocked:
141
  yield message
142
- if response_jailbroken_success(response_jailbreak):
143
- unlocked = True
144
- if response_jailbroken_failed(response_jailbreak):
145
- yield "Error: jailbreak failed. Try again."
146
- break
 
147
  else:
148
  yield from response
149
 
@@ -165,7 +166,7 @@ def response_jailbroken_failed(response):
165
  :param response: Response string
166
  :return: Boolean indicating if the response has not been jailbroken
167
  """
168
- return False if len(response) < 4 else not response.startswith("GPT:")
169
 
170
 
171
  def set_response_language(prompt):
 
134
  """
135
  if isJailbreak(jailbreak):
136
  response_jailbreak = ''
137
+ jailbroken_checked = False
138
  for message in response:
139
  response_jailbreak += message
140
+ if jailbroken_checked:
141
  yield message
142
+ else:
143
+ if response_jailbroken_success(response_jailbreak):
144
+ jailbroken_checked = True
145
+ if response_jailbroken_failed(response_jailbreak):
146
+ yield response_jailbreak
147
+ jailbroken_checked = True
148
  else:
149
  yield from response
150
 
 
166
  :param response: Response string
167
  :return: Boolean indicating if the response has not been jailbroken
168
  """
169
+ return False if len(response) < 4 else not (response.startswith ("GPT:") or response.startswith("ACT:"))
170
 
171
 
172
  def set_response_language(prompt):