Hội thoại nhiều lượt
Hãy mở rộng chatbot du lịch để cho phép người dùng phản hồi đề xuất ban đầu của mô hình. Bạn sẽ tiếp tục dùng lớp Conversation, nhưng lần này, bạn sẽ gọi mô hình nhiều lần để xem mô hình xử lý thông tin trước đó như thế nào.
Nhắc lại, đây là các phương thức từ lớp Conversation:
__init__(self, llm: Llama, system_prompt='', history=[])create_completion(self, user_prompt='')
Bài tập này là một phần của khóa học
Làm việc với Llama 3
Hướng dẫn bài tập
- Hỏi một gợi ý du lịch ban đầu, rồi đưa ra yêu cầu tiếp theo sau phản hồi đầu tiên của mô hình.
Bài tập tương tác thực hành trực tiếp
Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.
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)