当前位置: 首页 > web >正文

解决基于LangGraph框架的DeerFlow使用Qwen3不能正常被解析的问题

修改 langchain_core/output_parsers/json.py 文件里的 class JsonOutputParser()类,在其中的 parse_result() 方法中添加一个字符串替换:

    def parse_result(self, result: list[Generation], *, partial: bool = False) -> Any:"""Parse the result of an LLM call to a JSON object.Args:result: The result of the LLM call.partial: Whether to parse partial JSON objects.If True, the output will be a JSON object containingall the keys that have been returned so far.If False, the output will be the full JSON object.Default is False.Returns:The parsed JSON object.Raises:OutputParserException: If the output is not valid JSON."""text = result[0].text# 解决Qwen3固定输出<think>导致不能解析Json格式的问题if '<think>' in text:text = text[text.find('</think>') + len('</think>'):]text = text.strip()if partial:try:return parse_json_markdown(text)except JSONDecodeError:return Noneelse:try:return parse_json_markdown(text)except JSONDecodeError as e:msg = f"Invalid json output: {text}"raise OutputParserException(msg, llm_output=text) from e
http://www.xdnf.cn/news/12477.html

相关文章:

  • Edge(Bing)自动领积分脚本部署——基于python和Selenium(附源码)
  • 开源投屏工具Escrcpy的使用教程
  • MySQL基础2
  • F5 GSLB 最佳实践:如何手动将Wide IP 故障转移到另一个数据中心
  • Qt/C++开发监控GB28181系统/取流协议/同时支持udp/tcp被动/tcp主动
  • 链游技术破壁:NFT资产确权与Play-to-Earn经济模型实战
  • 从零开始基于Ubuntu18搭建Gazebo地图仿真环境
  • 【AI】智驾地图在不同自动驾驶等级中的作用演变
  • [opt 31-67] vivado编译出错 Implementation error 问题定位与解决
  • 【Linux】Linux 进程间通讯-管道
  • yolo 训练 中间可视化
  • 物联网嵌入式开发实训室建设方案探讨(高职物联网应用技术专业实训室建设)
  • TP6 实现一个字段对数组中的多个值进行LIKE模糊查询(OR逻辑)
  • Maven相关问题:jna版本与ES冲突 + aop失效
  • 前端面试题之ES6保姆级教程
  • 基于 BGE 模型与 Flask 的智能问答系统开发实践
  • Unity 中的颜色空间
  • 通道注意力
  • 逻辑回归与Softmax
  • 动量及在机器人控制中的应用
  • 打破数据孤岛:如何通过集成让AI真正“读懂”企业
  • 创客匠人:如何通过创始人IP打造实现知识变现与IP变现的长效增长?
  • 如何用 HTML 展示计算机代码
  • 什么?连接服务器也能可视化显示界面?:基于X11 Forwarding + CentOS + MobaXterm实战指南
  • Ubuntu 系统通过防火墙管控 Docker 容器
  • 思尔芯携手Andes晶心科技,加速先进RISC-V 芯片开发
  • 使用 Python 构建并调用 ComfyUI 图像生成 API:完整实战指南
  • Oracle自定义函数
  • 代理服务器-LVS的3种模式与调度算法
  • 7. 线性表的定义及特点