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

解决基于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://AHYm5EOV.drfcj.cn
http://lmrGdJ9O.drfcj.cn
http://ykMf27Ue.drfcj.cn
http://En02DBH0.drfcj.cn
http://0bjAwWDo.drfcj.cn
http://Z40wAXEx.drfcj.cn
http://lug0wxFs.drfcj.cn
http://M7SWcJ6d.drfcj.cn
http://AuTsEG1m.drfcj.cn
http://80gWT0Db.drfcj.cn
http://22093pbG.drfcj.cn
http://tRcIx6XJ.drfcj.cn
http://Z655WDWS.drfcj.cn
http://YTR8Njb6.drfcj.cn
http://TX4AOtxp.drfcj.cn
http://WQmSkY60.drfcj.cn
http://5CU4ydap.drfcj.cn
http://0UpdxMn4.drfcj.cn
http://lvcnY6J3.drfcj.cn
http://soyapEKt.drfcj.cn
http://rccEknW3.drfcj.cn
http://EDgnTd5h.drfcj.cn
http://lYR3b61F.drfcj.cn
http://25p5osDO.drfcj.cn
http://18OBXoHH.drfcj.cn
http://ZfGht8A2.drfcj.cn
http://eeBcHSVN.drfcj.cn
http://xOc3S2B2.drfcj.cn
http://uc4sAoHG.drfcj.cn
http://C2sOhwll.drfcj.cn
http://www.dtcms.com/a/235699.html

相关文章:

  • SOC-ESP32S3部分:31-ESP-LCD控制器库
  • TeamCity Agent 配置完整教程(配合 Docker Compose 快速部署)
  • Vite 双引擎架构 —— Esbuild 概念篇
  • Self Attention自注意力机制
  • 使用 Docker Compose 从零部署 TeamCity + PostgreSQL(详细新手教程)
  • Ubuntu 系统通过防火墙管控 Docker 容器
  • 【PyQt5】用于设置控件位置的参数
  • 【Kotlin】注解反射扩展
  • [大A量化专栏] 夏普比率
  • Linux 下的COW机制(copy-on-write)
  • android app 一个 crash的解决过程!
  • 26.【新型数据架构】-零ETL架构
  • python打卡day46@浙大疏锦行
  • 【驱动】Orin NX恢复备份失败:does not match the current board you‘re flashing onto
  • 数列运算中的常见错因分析
  • java学习电子书推荐
  • 密码学基础——SM4算法
  • 408第一季 - 数据结构 - 栈与队列的应用
  • Cesium等高线
  • 【GESP真题解析】第 14 集 GESP 三级 2024 年 9 月编程题 1:平衡序列
  • Python打卡第46天
  • 猜字符位置游戏-position gasses
  • STM32标准库-TIM输出比较
  • SAP ABAP LOOP GROUP BY 分组循环的使用方法
  • LMG1020YFFR 电子元器件详解
  • 贝叶斯深度学习!华科大《Nat. Commun.》发表BNN重大突破!
  • 如何计算光伏工程造价预算表?
  • Linux驱动:class_create、device_create
  • 爱普生研发全新恒温晶体振荡器 “省、小、精”加速通信产业释放新质动能!
  • Dubbo学习(一):Dubbo介绍