solon-ai-skill-restapi
2026年3月9日 上午11:09:15
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-ai-skill-restapi</artifactId>
</dependency>
1、描述
Solon AI 技能扩展,提供 restapi 能力的技能。。内置有 RestApiSkill
- RestApiSkill:智能 REST API 接入技能:实现从 API 定义到 AI 自动化调用的桥梁。
内部自带工具(相当于,LLM 通过这三个工具 “间接使用” 很多业务接口):
| 工具 | 描述 | 备注 |
|---|---|---|
| search_apis | 搜索接口 | 接口较少时,此工具会稳藏 |
| get_api_detail | 获取接口详情 | |
| call_api | 调用接口 |
关键属性说明:
| 属性 | 默认值 | 备注 |
|---|---|---|
| dynamicThreshold | 8 | 接口数少于 dynamicThreshold,则在系统提示词直接展示接口详情 |
| searchThreshold | 80 | 接口数大于 dynamicThreshold,小于 searchThreshold,则在系统提示词展示 name 和 description。如果大于 searchThreshold 则不展示,只引导通过搜索查找接口 |
| maxContextLength | 8000 | Text |
2、应用示例
String docUrl = "http://api.example.com/v3/api-docs";
String baseUrl = "http://api.example.com";
RestApiSkill apiSkill = new RestApiSkill();
apiSki.addApi(docUrl, baseUrl); //支持添加多套接口
SimpleAgent agent = SimpleAgent.of(chatModel) // 或 ChatModel,或 ReActAgent
.defaultSkillAdd(apiSkill)
.build();
agent.prompt("帮我查询 ID 为 1024 的用户状态").call();
agent.prompt("新建一个名为 'Noear' 的用户").call();