v0.1.4版本 #2
@ -4,11 +4,11 @@
|
||||
|
||||
## 核心程序
|
||||
|
||||
- [ ] 提示词调用完整实现:以面向对象形式取代字典形式,加入参数和描述
|
||||
- [x] 提示词调用完整实现:以面向对象形式取代字典形式,加入参数和描述
|
||||
- [ ] 接入本地文件系统等基础性MCP服务
|
||||
- [ ] Python代码执行的实现
|
||||
- [ ] 适配qwen3、deepseek等推理模型并迁移
|
||||
- [ ] 工具执行错误消息合并为一条
|
||||
- [x] 工具执行错误消息合并为一条
|
||||
|
||||
## 提示词工程
|
||||
|
||||
|
||||
@ -411,7 +411,7 @@ public class Gateway
|
||||
messages.Add(new Message
|
||||
{
|
||||
Role = "user",
|
||||
Content = toolResponse.IsError ? SystemPrompt.ErrorPromptTemplate : SystemPrompt.ContinuePrompt(JsonConvert.SerializeObject(toolResponse))
|
||||
Content = toolResponse.IsError ? SystemPrompt.ErrorPrompt(JsonConvert.SerializeObject(toolResponse)) : SystemPrompt.ContinuePrompt(JsonConvert.SerializeObject(toolResponse))
|
||||
});
|
||||
callback?.Invoke(toolMessageItem);
|
||||
}else if (mcpServer is StdioMcpServer)
|
||||
@ -431,7 +431,7 @@ public class Gateway
|
||||
messages.Add(new Message
|
||||
{
|
||||
Role = "user",
|
||||
Content = toolResponse.IsError ? SystemPrompt.ErrorPromptTemplate : SystemPrompt.ContinuePrompt(JsonConvert.SerializeObject(toolResponse))
|
||||
Content = toolResponse.IsError ? SystemPrompt.ErrorPrompt(JsonConvert.SerializeObject(toolResponse)) : SystemPrompt.ContinuePrompt(JsonConvert.SerializeObject(toolResponse))
|
||||
});
|
||||
callback?.Invoke(toolMessageItem);
|
||||
}else if (mcpServer is InnerMcpServer)
|
||||
@ -469,12 +469,7 @@ public class Gateway
|
||||
messages.Add(new Message
|
||||
{
|
||||
Role = "user",
|
||||
Content = SystemPrompt.ErrorPromptTemplate
|
||||
});
|
||||
messages.Add(new Message
|
||||
{
|
||||
Role = "user",
|
||||
Content = JsonConvert.SerializeObject(toolMessageItem)
|
||||
Content = SystemPrompt.ErrorPrompt(JsonConvert.SerializeObject(toolMessageItem))
|
||||
});
|
||||
callback?.Invoke(toolMessageItem);
|
||||
}else if (innerResult is JsonRpcSuccessEntity)
|
||||
|
||||
@ -22,7 +22,7 @@ public class SystemPrompt
|
||||
public static string ContinuePromptTemplate = "这是上述工具调用的结果。{{toolResult}}\n请根据以下执行结果,清晰解释执行结果并执行下一步操作。" +
|
||||
"执行下一步工具的要求:1. 解析工具输出结果2. 调用下一个工具时确保参数继承前序输出。请据此继续执行";
|
||||
|
||||
public static string ErrorPromptTemplate = "执行上一个工具的时候出现以下错误,需按以下流程处理:1. 错误解析:分析错误类型及具体原因(见下方错误信息),根据错误信息选择修复方案,```" +
|
||||
public static string ErrorPromptTemplate = "执行上一个工具的时候出现以下错误\n{{toolResult}}\n,需按以下流程处理:1. 错误解析:分析错误类型及具体原因(见下方错误信息),根据错误信息选择修复方案,```" +
|
||||
"2. 修复方案:(1)根据错误类型生成对应的工具重试策略(2)参数调整:明确需要修改的参数及修改方式。3. 工具重试:使用调整后的参数重新调用工具。错误信息如下,请根据报错信息重试,4.如果没有具体的错误描述信息请检查输出文件是否已经存在,若已经存在默认执行成功"+
|
||||
"5.查询可能相关的知识库和帮助文档,纠正调用参数中存在的错误";
|
||||
|
||||
@ -40,4 +40,11 @@ public class SystemPrompt
|
||||
continuePrompt = continuePrompt.Replace("{{toolResult}}", toolResult);
|
||||
return continuePrompt;
|
||||
}
|
||||
|
||||
public static string ErrorPrompt(string toolResult)
|
||||
{
|
||||
string errPrompt = ErrorPromptTemplate;
|
||||
errPrompt = errPrompt.Replace("{{toolResult}}", toolResult);
|
||||
return errPrompt;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user