สร้าง prompt สำหรับ sequential chains
ในแบบฝึกหัดชุดนี้ คุณจะสร้างระบบช่วยผู้เรียนพัฒนาทักษะใหม่ ระบบนี้ต้องทำงานแบบลำดับขั้น เพื่อให้ผู้เรียนปรับแผนตามความต้องการและข้อจำกัดของตนเองได้ คุณจะใช้ทักษะ LCEL ของ LangChain เพื่อสร้าง sequential chain และขั้นตอนแรกคือการออกแบบ prompt templates ที่ระบบนี้จะใช้งาน
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การพัฒนาแอปพลิเคชัน LLM ด้วย LangChain
คำแนะนำการฝึกหัด
- สร้าง prompt template ชื่อ
learning_promptที่รับ input"activity"และสร้างแผนการเรียนรู้ - สร้าง prompt template ชื่อ
time_promptที่รับ input"learning_plan"และปรับแผนให้พอดีกับ หนึ่งสัปดาห์ - เรียกใช้
learning_promptด้วย activity ที่ต้องการ (ลอง"play golf"หากยังนึกไม่ออก)
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Create a prompt template that takes an input activity
learning_prompt = PromptTemplate(
input_variables=["____"],
template="I want to learn how to {activity}. Can you suggest how I can learn this step-by-step?"
)
# Create a prompt template that places a time constraint on the output
time_prompt = PromptTemplate(
____,
template="I only have one week. Can you create a plan to help me hit this goal: {learning_plan}."
)
# Invoke the learning_prompt with an activity
print(learning_prompt.____({"activity": "____"}))