fix(ch4): parse answer_box_list objects - #858
Draft
linhongyu510 wants to merge 2 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
answer_box_list是答案框对象列表。当前代码直接执行"\n".join(results["answer_box_list"]),当列表元素为字典时会触发:这会让
search()捕获异常并把错误文本返回给 Agent,而不是返回搜索答案。Refs #849
改动
answer后再拼接。answer时继续尝试单个answer_box、知识图谱和自然结果,避免提前返回空字符串。SerpApi 官方资料说明多答案通过
answer_box_list数组返回:https://serpapi.com/direct-answer-box-api
验证
另外按教程依赖安装
google-search-results==2.4.2,使用真实SerpApiClient类并仅 mockget_dict()的网络结果完成 smoke test,确认两个答案输出为
first\nsecond。未使用真实 API key,也未发起外部SerpApi 请求。
竞争与范围
answer_box_list符号和近期提交,未发现同主题实现。join(dict)逻辑;本 PR 不改变 SDK 选择或依赖版本。