当前位置: 首页 > 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

相关文章:

  • 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:平衡序列
  • 崇明注册公司/seo快速优化软件网站
  • 有什么正网站做兼职的/windows优化大师要会员
  • 3g网站建设/生意参谋指数在线转换
  • 做兼职的国外网站/山东疫情最新消息
  • 做垂直行业网站利润分析/2345手机浏览器
  • 建设银行宁德分行网站/搜索引擎排名优化程序