Spaces:
Sleeping
Sleeping
JohnSmith9982
commited on
Commit
•
c9c16d7
1
Parent(s):
6e4ef35
Update modules/chat_func.py
Browse files- modules/chat_func.py +10 -2
modules/chat_func.py
CHANGED
@@ -253,6 +253,14 @@ def predict_all(
|
|
253 |
status_text = standard_error_msg + str(response)
|
254 |
return chatbot, history, status_text, all_token_counts
|
255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
|
257 |
def predict(
|
258 |
openai_api_key,
|
@@ -271,8 +279,8 @@ def predict(
|
|
271 |
should_check_token_count=True,
|
272 |
): # repetition_penalty, top_k
|
273 |
logging.info("输入为:" + colorama.Fore.BLUE + f"{inputs}" + colorama.Style.RESET_ALL)
|
274 |
-
if
|
275 |
-
print("有人来浪费了")
|
276 |
yield chatbot+[(inputs, "🖕️🖕️🖕️🖕️🖕️看不起你")], history, "🖕️🖕️🖕️🖕️🖕️🖕️", all_token_counts
|
277 |
return
|
278 |
if should_check_token_count:
|
|
|
253 |
status_text = standard_error_msg + str(response)
|
254 |
return chatbot, history, status_text, all_token_counts
|
255 |
|
256 |
+
def is_repeated_string(s):
|
257 |
+
n = len(s)
|
258 |
+
for i in range(1, n // 2 + 1):
|
259 |
+
if n % i == 0:
|
260 |
+
sub = s[:i]
|
261 |
+
if sub * (n // i) == s:
|
262 |
+
return True
|
263 |
+
return False
|
264 |
|
265 |
def predict(
|
266 |
openai_api_key,
|
|
|
279 |
should_check_token_count=True,
|
280 |
): # repetition_penalty, top_k
|
281 |
logging.info("输入为:" + colorama.Fore.BLUE + f"{inputs}" + colorama.Style.RESET_ALL)
|
282 |
+
if is_repeated_string(inputs):
|
283 |
+
print("================== 有人来浪费了 ======================")
|
284 |
yield chatbot+[(inputs, "🖕️🖕️🖕️🖕️🖕️看不起你")], history, "🖕️🖕️🖕️🖕️🖕️🖕️", all_token_counts
|
285 |
return
|
286 |
if should_check_token_count:
|