Skip to content

Commit 8a84db5

Browse files
wuayeewuayee
andauthored
[app-builder] Added process display of intelligent agent calling tool (#492)
Co-authored-by: wuayee <[email protected]>
1 parent 223be4f commit 8a84db5

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

app-builder/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/service/impl/AgentInfoGenerateServiceImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,16 @@ public String generateGreeting(String desc, OperationContext context) {
107107

108108
@Override
109109
public String generatePrompt(String desc, OperationContext context) {
110-
return this.generateByTemplate(desc, "prompt/promptGeneratePrompt.txt", context);
110+
String prompt = this.generateByTemplate(desc, "prompt/promptGeneratePrompt.txt", context);
111+
String format;
112+
try {
113+
format = IoUtils.content(AgentInfoGenerateService.class.getClassLoader(),
114+
"prompt/promptGeneratePromptFormat.txt");
115+
} catch (IOException e) {
116+
log.error("read prompt format file fail.", e);
117+
throw new AippException(AippErrCode.EXTRACT_FILE_FAILED);
118+
}
119+
return StringUtils.format(format, prompt);
111120
}
112121

113122
@Override

app-builder/plugins/aipp-plugin/src/main/resources/prompt/promptGeneratePrompt.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
You ara a prompt generator, Your job is to generate prompt from the input of the user.
1+
You are a prompt generator, Your job is to generate prompt from the input of the user.
22
**NOTE THAT THE PROMPT MUST INSTRUCT THE AGENT TO USE TOOL AS MUCH AS POSSIBLE**
33

44
The Prompt must follow the style of the example below:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{0}
2+
3+
<tool_usage>
4+
你的回答有两种情况:
5+
6+
无需调用外部工具:
7+
如果问题可通过已有对话历史或直接推理得到答案,直接输出最终结果,不需使用任何标签包装,也不显示详细思考过程。
8+
9+
需要调用外部工具解决的复杂问题:
10+
必须采用以下严格的标签体系输出,每个标签之间空一行,且仅展示真实的工具调用结果:
11+
<reasoning>...</reasoning>:展示你内部的思考过程。注意,这部分内容可以展示给用户,但仅限于描述思路,不应包含任何伪造的工具调用结果。
12+
<step>...</step>:描述你准备调用工具的原因和计划。此处仅说明你需要调用哪个工具以及原因,工具的名称对人类阅读要友好,切勿直接模拟或输出工具返回内容。
13+
<tool>...</tool>:当你真正调用某个工具后,等待工具反馈,然后将工具调用的返回结果做非常简略的摘要后放在此标签内,摘要字数在20字以内。绝对禁止在未获得真实工具反馈前预先构造。 <tool> 标签内容。
14+
<final>...</final>:在获取所有真实工具调用结果后,将整合信息给出最终答案。
15+
重要要求:
16+
- 无论用户是否明确要求展示思考过程,都要展示思考过程
17+
- 不要输出tool_call标签。
18+
- 答案必须详细完整,不仅仅是工具返回结果的简单总结,而是对结果进行深入分析和整合,并提供背景解释、推理过程和可行性分析。
19+
- 确保所有关键信息得到展开,避免省略任何重要内容。
20+
- 如果适用,可以提供额外的解释、使用建议或应用场景,以增强回答的实用性。
21+
- 请使用标准 Markdown 语法输出答案,保证语法完整,不要拆分列表结构。
22+
- 输出此标签后,不得追加任何其他内容或标签。
23+
严格要求:
24+
切勿在中间思考或工具调用计划中,提前生成伪造的 <tool> 或 <final> 标签内容。必须在实际调用工具并获得反馈后,再以 <tool> 标签展示真实结果,再生成 <final> 标签输出最终答案。
25+
如果历史对话中已包含真实的工具调用结果,应直接使用这些信息构造最终答案,避免重复调用或展示多余标签。
26+
在所有工具调用完成之前,不得输出 <final> 标签;只有在确认所有真实工具反馈后,才生成最终答案。
27+
</tool_usage>

app-builder/plugins/aipp-plugin/src/test/java/modelengine/fit/jober/aipp/service/AgentInfoGenerateServiceImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void shouldOkWhenGeneratePrompt() {
102102
when(model.getTag()).thenReturn("llm_tag");
103103
when(this.aippModelCenter.getDefaultModel(any(), any())).thenReturn(model);
104104
when(aippModelService.chat(anyString(), anyString(), anyDouble(), anyString())).thenReturn("PROMPT");
105-
assertThat(this.agentInfoGenerateService.generatePrompt("DESC", null)).isEqualTo("PROMPT");
105+
assertThat(this.agentInfoGenerateService.generatePrompt("DESC", null)).startsWith("PROMPT");
106106
}
107107

108108
@Test

0 commit comments

Comments
 (0)