Day 46 · 规划与分解

Week 7 · Day 46 / 56 · 返回大纲

一、任务分解

def plan_task(task):
    prompt = f"把任务分解为子任务JSON:{task}"
    resp = client.messages.create(...)
    return json.loads(resp.content[0].text)

def execute_plan(plan):
    for step in plan["steps"]:
        result = agent_loop(step, tools)
        print(f"完成:{step}")

动手练习

分解
分解复杂任务
plan_task("print 改 logging")
查看答案
参考答案
plan_task("print 改 logging")
执行
逐步执行
for step in plan['steps']
查看答案
参考答案
for step in plan['steps']

打卡验收

理解规划与分解核心概念
能看懂代码示例
能独立写代码
代码能跑通
完成练习
能向别人解释
Week 7 进度
继续学习
打卡方式: 全部勾选后,告诉我 "Day 46 打卡",并贴出你的代码。