Skip to content

[问题/Issue] 章节7.4:测试代码 test_reflection_agent.py 中自定义提示词和问题不匹配 #362

@Nikolas-Cao

Description

@Nikolas-Cao

1. 遇到问题的章节 / Affected Chapter

Chapter7.4.3

2. 问题类型 / Issue Type

代码错误 / Code Error

3. 具体问题描述 / Problem Description

pdf中7.4.3节代码如下,自定义提示词是想要“编写高效python代码”,但是问题却是“写文章”。
是为了测试健壮性而故意这么设置的不匹配?

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}")

4. 问题重现材料 / Reproduction Materials

N/A

5. 补充信息 / Additional Information

N/A

确认事项 / Verification

  • 我已阅读过相关章节的文档 / I have read the relevant chapter documentation
  • 我已搜索过现有的Issues,确认此问题未被报告 / I have searched existing Issues and confirmed this hasn't been reported
  • 我已尝试过基本的故障排除(如重启、重新安装依赖等) / I have tried basic troubleshooting (restart, reinstall dependencies, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions