Open
Conversation
- 实现多阶段JSON清理策略,支持Markdown代码块、注释、单引号等格式修复 - 创建ParseResult记录类和ParseStage枚举,提供解析状态和错误信息 - 集成Hook机制,自动拦截PreActingEvent并修正ToolUseBlock中的参数 - 包含完整的单元测试 - 提供详细的README文档和使用示例
- 在 pom.xml 中新增 agentscope-extensions-tool-parser 模块配置
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
- 在 BOM 中添加 agentscope-extensions-tool-parser 依赖
- 在 pom.xml 中新增 agentscope-extensions-tool-parser 依赖配置
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.
#847
AgentScope-Java Version
1.0.10-SNAPSHOT
背景
在 LLM 工具调用场景中,模型输出的工具参数 JSON 格式可能 由于模型的能力导致输出格式不规范,常见问题包括:
这些格式问题导致标准 JSON 解析器无法正确处理,需要一种健壮的参数解析和修正机制。
目的
本 PR 新增 agentscope-extensions-tool-parser 扩展模块,提供:
变更内容
1. 核心解析器(ToolArgumentParser)
新增文件:
关键特性:
2. Hook 集成(ToolArgumentParserHook)
新增文件:
工作原理:
使用示例:
// 创建 Hook 并注册到 Agent
ToolArgumentParserHook hook = new ToolArgumentParserHook();
ReActAgent agent = ReActAgent.builder()
.name("Assistant")
.model(model)
.toolkit(toolkit)
.hooks(List.of(hook))
.build();
3. 模块配置
新增文件:
依赖管理:
4. 测试覆盖
新增文件:
测试类别:
5. 文档
新增文件: