fix: f-string expression part cannot include a backslash (#2139)

这个提交包含在:
Steven Moder
2025-02-08 20:50:54 +08:00
提交者 GitHub
父节点 cf7c81170c
当前提交 991a903fa9

查看文件

@@ -252,9 +252,9 @@ def get_predict_function(
logger.error(error_msg) logger.error(error_msg)
raise RuntimeError("Json解析不合常规") raise RuntimeError("Json解析不合常规")
if reasoning: if reasoning:
return f'''<div style="padding: 1em; line-height: 1.5; text-wrap: wrap; opacity: 0.8"> style = 'padding: 1em; line-height: 1.5; text-wrap: wrap; opacity: 0.8'
{''.join([f'<p style="margin: 1.25em 0;">{line}</p>' for line in reasoning_buffer.split('\n')])} paragraphs = ''.join([f'<p style="margin: 1.25em 0;">{line}</p>' for line in reasoning_buffer.split('\n')])
</div>\n\n''' + result return f'''<div style="{style}">{paragraphs}</div>\n\n''' + result
return result return result
def predict( def predict(
@@ -390,9 +390,9 @@ def get_predict_function(
if reasoning: if reasoning:
gpt_replying_buffer += response_text gpt_replying_buffer += response_text
gpt_reasoning_buffer += reasoning_content gpt_reasoning_buffer += reasoning_content
history[-1] = f'''<div style="padding: 1em; line-height: 1.5; text-wrap: wrap; opacity: 0.8"> style = 'padding: 1em; line-height: 1.5; text-wrap: wrap; opacity: 0.8'
{''.join([f'<p style="margin: 1.25em 0;">{line}</p>' for line in gpt_reasoning_buffer.split('\n')])} paragraphs = ''.join([f'<p style="margin: 1.25em 0;">{line}</p>' for line in gpt_reasoning_buffer.split('\n')])
</div>\n\n''' + gpt_replying_buffer history[-1] = f'<div style="{style}">{paragraphs}</div>\n\n' + gpt_replying_buffer
else: else:
gpt_replying_buffer += response_text gpt_replying_buffer += response_text
# 如果这里抛出异常,一般是文本过长,详情见get_full_error的输出 # 如果这里抛出异常,一般是文本过长,详情见get_full_error的输出