Skip to content

Commit

Permalink
fix: f-string expression part cannot include a backslash (#2139)
Browse files Browse the repository at this point in the history
  • Loading branch information
SakuraPuare authored Feb 8, 2025
1 parent cf7c811 commit 991a903
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions request_llms/oai_std_model_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ def predict_no_ui_long_connection(
logger.error(error_msg)
raise RuntimeError("Json解析不合常规")
if reasoning:
return f'''<div 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')])}
</div>\n\n''' + result
style = 'padding: 1em; line-height: 1.5; text-wrap: wrap; opacity: 0.8'
paragraphs = ''.join([f'<p style="margin: 1.25em 0;">{line}</p>' for line in reasoning_buffer.split('\n')])
return f'''<div style="{style}">{paragraphs}</div>\n\n''' + result
return result

def predict(
Expand Down Expand Up @@ -390,9 +390,9 @@ def predict(
if reasoning:
gpt_replying_buffer += response_text
gpt_reasoning_buffer += reasoning_content
history[-1] = f'''<div 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')])}
</div>\n\n''' + gpt_replying_buffer
style = 'padding: 1em; line-height: 1.5; text-wrap: wrap; opacity: 0.8'
paragraphs = ''.join([f'<p style="margin: 1.25em 0;">{line}</p>' for line in gpt_reasoning_buffer.split('\n')])
history[-1] = f'<div style="{style}">{paragraphs}</div>\n\n' + gpt_replying_buffer
else:
gpt_replying_buffer += response_text
# 如果这里抛出异常,一般是文本过长,详情见get_full_error的输出
Expand Down

0 comments on commit 991a903

Please sign in to comment.