Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ public String generateGreeting(String desc, OperationContext context) {

@Override
public String generatePrompt(String desc, OperationContext context) {
return this.generateByTemplate(desc, "prompt/promptGeneratePrompt.txt", context);
String prompt = this.generateByTemplate(desc, "prompt/promptGeneratePrompt.txt", context);
String format;
try {
format = IoUtils.content(AgentInfoGenerateService.class.getClassLoader(),
"prompt/promptGeneratePromptFormat.txt");
} catch (IOException e) {
log.error("read prompt format file fail.", e);
throw new AippException(AippErrCode.EXTRACT_FILE_FAILED);
}
return StringUtils.format(format, prompt);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
You ara a prompt generator, Your job is to generate prompt from the input of the user.
You are a prompt generator, Your job is to generate prompt from the input of the user.
**NOTE THAT THE PROMPT MUST INSTRUCT THE AGENT TO USE TOOL AS MUCH AS POSSIBLE**

The Prompt must follow the style of the example below:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{0}

<tool_usage>
你的回答有两种情况:

无需调用外部工具:
如果问题可通过已有对话历史或直接推理得到答案,直接输出最终结果,不需使用任何标签包装,也不显示详细思考过程。

需要调用外部工具解决的复杂问题:
必须采用以下严格的标签体系输出,每个标签之间空一行,且仅展示真实的工具调用结果:
<reasoning>...</reasoning>:展示你内部的思考过程。注意,这部分内容可以展示给用户,但仅限于描述思路,不应包含任何伪造的工具调用结果。
<step>...</step>:描述你准备调用工具的原因和计划。此处仅说明你需要调用哪个工具以及原因,工具的名称对人类阅读要友好,切勿直接模拟或输出工具返回内容。
<tool>...</tool>:当你真正调用某个工具后,等待工具反馈,然后将工具调用的返回结果做非常简略的摘要后放在此标签内,摘要字数在20字以内。绝对禁止在未获得真实工具反馈前预先构造。 <tool> 标签内容。
<final>...</final>:在获取所有真实工具调用结果后,将整合信息给出最终答案。
重要要求:
- 无论用户是否明确要求展示思考过程,都要展示思考过程
- 不要输出tool_call标签。
- 答案必须详细完整,不仅仅是工具返回结果的简单总结,而是对结果进行深入分析和整合,并提供背景解释、推理过程和可行性分析。
- 确保所有关键信息得到展开,避免省略任何重要内容。
- 如果适用,可以提供额外的解释、使用建议或应用场景,以增强回答的实用性。
- 请使用标准 Markdown 语法输出答案,保证语法完整,不要拆分列表结构。
- 输出此标签后,不得追加任何其他内容或标签。
严格要求:
切勿在中间思考或工具调用计划中,提前生成伪造的 <tool> 或 <final> 标签内容。必须在实际调用工具并获得反馈后,再以 <tool> 标签展示真实结果,再生成 <final> 标签输出最终答案。
如果历史对话中已包含真实的工具调用结果,应直接使用这些信息构造最终答案,避免重复调用或展示多余标签。
在所有工具调用完成之前,不得输出 <final> 标签;只有在确认所有真实工具反馈后,才生成最终答案。
</tool_usage>
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void shouldOkWhenGeneratePrompt() {
when(model.getTag()).thenReturn("llm_tag");
when(this.aippModelCenter.getDefaultModel(any(), any())).thenReturn(model);
when(aippModelService.chat(anyString(), anyString(), anyDouble(), anyString())).thenReturn("PROMPT");
assertThat(this.agentInfoGenerateService.generatePrompt("DESC", null)).isEqualTo("PROMPT");
assertThat(this.agentInfoGenerateService.generatePrompt("DESC", null)).startsWith("PROMPT");
}

@Test
Expand Down