code_prompts = {
"initial": "你是Python专家,请编写函数:{task}",
"reflect": "请审查代码的算法效率:\n任务:{task}\n代码:{content}",
"refine": "请根据反馈优化代码:\n任务:{task}\n反馈:{feedback}"
}
code_agent = MyReflectionAgent(
name="我的代码生成助手",
llm=llm,
custom_prompts=code_prompts
)
# 测试使用
result = general_agent.run("写一篇关于人工智能发展历程的简短文章")
print(f"最终结果: {result}")
1. 遇到问题的章节 / Affected Chapter
Chapter7.4.3
2. 问题类型 / Issue Type
代码错误 / Code Error
3. 具体问题描述 / Problem Description
pdf中7.4.3节代码如下,自定义提示词是想要“编写高效python代码”,但是问题却是“写文章”。
是为了测试健壮性而故意这么设置的不匹配?
4. 问题重现材料 / Reproduction Materials
N/A
5. 补充信息 / Additional Information
N/A
确认事项 / Verification