ragflow报错:KeyError: ‘\n “序号“‘

发布于:2025-05-11 ⋅ 阅读:(11) ⋅ 点赞:(0)

环境:

ragflowv 0.17.2

问题描述:

ragflow报错:KeyError: ‘\n “序号”’

**1. 推荐表(输出json格式)**
[
  {
    "
  },
  {
    
  },
  {
    "
  },
  {
   
  }
]
raceback (most recent call last):
May 08 20:06:09 VM-0-2-ubuntu ragflow-start.sh[2745493]:   File "/mnt/code/ragflow/api/apps/conversation_app.py", line 232, in stream
May 08 20:06:09 VM-0-2-ubuntu ragflow-start.sh[2745493]:     for ans in chat(dia, msg, True, **req):
May 08 20:06:09 VM-0-2-ubuntu ragflow-start.sh[2745493]:   File "/mnt/code/ragflow/api/db/services/dialog_service.py", line 313, in chat
May 08 20:06:09 VM-0-2-ubuntu ragflow-start.sh[2745493]:     msg = [{"role": "system", "content": prompt_config["system"].format(**kwargs)}]
May 08 20:06:09 VM-0-2-ubuntu ragflow-start.sh[2745493]: KeyError: '\n    "志愿序号"'
May 08 20:06:09 VM-0-2-ubuntu ragflow-start.sh[2745493]: 2025-05-08 20:06:09,687 INFO     2745493 127.0.0.1 - - [08/May/2025 20:06:09] "POST /v1/conversatio

解决方案:

这个字符串中存在一个格式化占位符,形如 {…},需要用kwargs中的键去替换,但在 kwargs 字典中没有对应的键 ‘\n “志愿序号“‘

1.更改去掉{}

**1. 推荐表(输出json格式)**
[
    "序号": "志愿1",
    "概率": "37%",
    "建议": "冲",
    "专业": "机械设计制造及其自动化"
,
  
    "序号": "志愿2",
    "概率": "33%",
    "建议": "稳",
    "专业": "电子信息类"
  ,
  
    "序号": "志愿3",
    "概率": "30%",
    "建议": "保",
    "专业": "电气工程及其自动化"
 ,
  
    "志愿序号": "志愿4",
    "概率": "28%",
    "建议": "难",
    "专业": "计算机类"
  ]

恢复正常
在这里插入图片描述


网站公告

今日签到

点亮在社区的每一天
去签到