优化代码! 真的最有一次优化isay的逻辑了!!!!

This commit is contained in:
w_xiaolizu
2023-06-16 20:01:44 +08:00
parent 4774dad8ab
commit d1531c9ddc
6 changed files with 76 additions and 62 deletions

View File

@ -259,6 +259,7 @@ def report_execption(chatbot, history, a, b):
import re
def text_divide_paragraph(input_str):
if input_str:
# 提取所有的代码块
@ -284,13 +285,13 @@ def text_divide_paragraph(input_str):
else:
# 对于没有反引号的字符串,针对四个空格之前的换行符进行处理
lines = input_str.split('\n')
if not any(line.startswith(' ') for line in lines):
for idx, line in enumerate(lines[:-1]):
if not line.strip():
continue
if not (lines[idx + 1].startswith(' ') or lines[idx + 1].startswith('\t')):
lines[idx] += '\n' # 将一个换行符替换为两个换行符
for idx, line in enumerate(lines[:-1]):
if not line.strip():
continue
if not (lines[idx + 1].startswith(' ') or lines[idx + 1].startswith('\t')):
lines[idx] += '\n' # 将一个换行符替换为两个换行符
input_str = '\n'.join(lines)
return input_str