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%",
    "建议": "难",
    "专业": "计算机类"
  ]

恢复正常

相关推荐
李燚1 小时前
Checkpoint 源码:Agent 执行到一半怎么保存(第80篇-E66)
人工智能·ai·aigc·agent·checkpoint·rag·eino
johnny2331 小时前
RAG(四):OpenRAG、Ragflow-Plus、LinearRAG、Cache-AG、Context-AG
rag
circuitsosk1 天前
Prompt Engineering进阶:面向复杂业务场景的模板化管理与动态注入策略
python·langchain·prompt·跨境电商·rag·上下文管理·动态注入
染指11102 天前
79.高级RAG-md文档元素分割器
markdown·rag·llama_index·llamaindex
xian_wwq2 天前
【学习笔记】RAG 只是 Context Engineering 的一小块-5/16
笔记·学习·rag
染指11102 天前
80.高级RAG-LLamaIndex实际应用-金融助手
人工智能·rag·llama_index·llamaindex
阿图灵2 天前
Agentic AI 架构入门(三):Agent 的七大组件与 PRAL 循环
人工智能·架构·llm·rag·ai agent·智能体·agentic ai
VipSoft2 天前
LangChain — RAG 知识库(实操)
langchain·rag
Tbisnic4 天前
LangChain的 六大核心组件与 RAG 知识库构建
人工智能·python·ai·langchain·rag·langgraph