Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: SyntaxError: f-string expression part cannot include a backslash #2137

Closed
DengZhiyuan-math opened this issue Feb 7, 2025 · 4 comments · Fixed by #2139
Closed

[Bug]: SyntaxError: f-string expression part cannot include a backslash #2137

DengZhiyuan-math opened this issue Feb 7, 2025 · 4 comments · Fixed by #2139

Comments

@DengZhiyuan-math
Copy link

Installation Method | 安装方法与平台

Pip Install (I used latest requirements.txt)

Version | 版本

Latest | 最新版

OS | 操作系统

Mac

Describe the bug | 简述

在今天git pull,更新版本后,无法打开main.py. 提示错误为SyntaxError: f-string expression part cannot include a backslash

Screen Shot | 有帮助的截图

Image

Terminal Traceback & Material to Help Reproduce Bugs | 终端traceback(如有) + 帮助我们复现的测试材料样本(如有)

No response

@aierm
Copy link

aierm commented Feb 7, 2025

   if reasoning:
        newline = '\n'
        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(newline)])}

找到 request_llms/oai_std_model_template.py 第257行,添加 newline = '\n',然后将reasoning_buffer.split('\n')替换成reasoning_buffer.split(newline),我是这样解决的,397行也是一样的

Image

@hilbert9221
Copy link

我也遇到了这个问题,有一种解决方法是把 f'Anything\n\n' 替换成 'Anything{}'.format('\n\n'),也就是把 f-string 替换成 '{}'.format()。据称在 Python 3.12 里 f-string 可以支持反斜杠了,参考链接

@SakuraPuare
Copy link
Contributor

抱歉没有考虑到兼容性问题,PEP498中提到了这一点。我将尽快修复这个问题

@SakuraPuare
Copy link
Contributor

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants