เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

การสนทนาแบบหลายรอบ

มาต่อยอด travel chatbot ให้ผู้ใช้สามารถตอบกลับคำแนะนำเริ่มต้นของโมเดลได้ คราวนี้จะใช้คลาส Conversation เช่นเดิม แต่จะเรียกโมเดลซ้ำหลายครั้งเพื่อดูว่าโมเดลจัดการกับข้อมูลจากการสนทนาก่อนหน้าอย่างไร

เพื่อเป็นการทบทวน นี่คือเมธอดต่าง ๆ จากคลาส Conversation:

  • __init__(self, llm: Llama, system_prompt='', history=[])
  • create_completion(self, user_prompt='')

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การทำงานกับ Llama 3

ดูคอร์ส

คำแนะนำการฝึกหัด

  • ขอคำแนะนำการท่องเที่ยวเบื้องต้น จากนั้นส่งคำถามติดตามผลหลังจากได้รับการตอบกลับครั้งแรกจากโมเดล

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

chatbot = Conversation(llm, system_prompt="You are a travel expert that recommends a travel destination based on a prompt. Return the location name only as 'City, Country'.")

# Ask for the initial travel recommendation
first_recommendation = chatbot.____("Recommend a Spanish-speaking city.")
print(first_recommendation)

# Add an additional request to update the recommendation
second_recommendation = chatbot.____("A different city in the same country")
print(second_recommendation)
แก้ไขและรันโค้ด