Skip to content

01-Qwen1.5-7B-Chat FastApi 部署调用.md 传入数据错误 #128

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

Open
cqray1990 opened this issue Jun 1, 2024 · 1 comment
Open

01-Qwen1.5-7B-Chat FastApi 部署调用.md 传入数据错误 #128

cqray1990 opened this issue Jun 1, 2024 · 1 comment

Comments

@cqray1990
Copy link

cqray1990 commented Jun 1, 2024

当传入一个html 文本数据的时候就会出错

curl -X POST "http://0.0.0.0:8000" -H 'Content-Type: application/json' -d '{"promt": "

科目区间单价应缴金额上次
公费2024.2.26-2024.3.260.707114368.27167311698520320
2024.2.26-2024.3.266.351574.81252412772248
大写壹万伍仟玖佰肆拾叁元零柒分
合计15943.07
","history":[]}'

传入以上数据html文本的时候,页面自动渲染出来表格了,实际是一个html的文本:报以下错误,json解析不了,不能传html文本?只是一个文本而已为什么不能解析?传其他的文本就可以跑

File "/home/user/chatglm/llm_ki/fastapi_demo.py", line 41, in create_item
json_post_raw = await request.json()
File "y/lib/python3.10/site-packages/starlette/requests.py", line 252, in json
self._json = json.loads(body)
File "y/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "y/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "y/lib/python3.10/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 18 (char 17)

422 Unprocessable Entity

@KMnO4-zx
Copy link
Contributor

KMnO4-zx commented Jun 3, 2024

问题的根源在于 JSON 格式中包含了特殊字符,比如 HTML 标签,这些字符需要被转义或以字符串的形式正确传递。

解决方案可以将 HTML 内容进行转义,或者将其作为字符串传递,确保 JSON 解析器可以正确处理。

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

No branches or pull requests

2 participants