开始使用免费开始使用

构建多消息对话

Aurora Robotics 的主管请您为一场全新的工作坊做准备,主题为"Introduction to Robotics in Manufacturing",面向的受众是没有机器人学背景的制造业从业者。与其把所有需求都塞进一个大提示词,您将与 Claude 搭建一个多消息对话:先请求给出大纲草案,然后再根据非技术型的制造业受众进行细化。

anthropic 库和 client 已预加载。

本练习是课程的一部分

Claude 模型入门

查看课程

练习说明

  • 添加第一条用户消息,请 Claude 帮忙规划主题为 "Introduction to Robotics in Manufacturing" 的工作坊。
  • 再添加一条跟进的用户消息,明确受众为 "manufacturing industry professionals with no robotics background"

交互式实操练习

通过完成这段示例代码来试试这个练习。

messages = []

# Add first user message asking for workshop help
messages.append({"role": "user", "content": ____})

response = client.messages.create(model="claude-sonnet-4-6", max_tokens=200, messages=messages)

messages.append({"role": "assistant", "content": response.content[0].text})

# Add follow-up message specifying target audience
messages.append({"role": "user", "content": ____})
编辑并运行代码