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

环境:

ragflowv 0.17.2

问题描述:

ragflow报错:KeyError: '\n "序号"'

bash 复制代码
**1. 推荐表(输出json格式)**
[
  {
    "
  },
  {
    
  },
  {
    "
  },
  {
   
  }
]
bash 复制代码
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.更改去掉{}

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

恢复正常

相关推荐
温柔哥`3 小时前
PANDA:通过代理型 AI 工程师迈向通用视频异常检测
大模型·agent·rag·vad·视频异常检测·工具调用·mllms
一个帅气昵称啊1 天前
在.NET中使用RAG检索增强AI基于Qdrant的矢量化数据库
ai·性能优化·c#·.net·rag·qdrant
陈果然DeepVersion2 天前
Java大厂面试真题:从Spring Boot到AI微服务的三轮技术拷问
spring boot·redis·微服务·ai·智能客服·java面试·rag
陈果然DeepVersion3 天前
Java大厂面试真题:从Spring Boot到AI微服务的三轮技术拷问(二)
spring boot·redis·spring cloud·微服务·ai·java面试·rag
c++服务器开发4 天前
掌握RAG系统的七个优秀GitHub存储库
人工智能·python·github·rag
cooldream20096 天前
构建智能知识库问答助手:LangChain与大语言模型的深度融合实践
人工智能·语言模型·langchain·rag
大千AI助手8 天前
Graph-R1:智能图谱检索增强的结构化多轮推理框架
人工智能·神经网络·大模型·rag·检索增强生成·大千ai助手·graph-r1