fix(model): enhance response parsing robustness for non-standard outputs #144
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.
标题
fix(model): 增强响应解析的鲁棒性,兼容非标准模型输出
描述
PR 类型
当前行为 (Current Behavior)
phone_agent/model/client.py中的_parse_response方法目前严格依赖<answer>标签来分割“思考过程”和“动作指令”。然而,许多模型(特别是通过 ModelScope 或 BigModel 等第三方 API 调用时)经常会生成以下格式的输出:
<answer>标签。</think>标签。这会导致程序抛出
ValueError: Failed to parse action异常并终止运行。新行为 (New Behavior)
本 PR 在
_parse_response中实现了更鲁棒的多级解析策略:<answer>标签(保持向后兼容)。<answer>,尝试使用</think>进行分割。do(...)或finish(...)指令。测试计划 (Test Plan)
AutoGLM-Phone-9B模型进行了测试。<answer>标签的响应现在可以被正确解析。<think>标签未闭合的响应现在可以被正确解析。