단일 턴 대화
이제 Conversation 클래스를 직접 사용해 볼 차례예요! 이 클래스를 활용해 여행 추천 챗봇을 만들어 봅니다. 원하는 조건이나 설명을 입력하면, 모델이 적합한 여행지를 추천해 줍니다.
이전 연습 문제에서 만든 Conversation 클래스는 다음 메서드와 함께 계속 사용할 수 있어요:
__init__(self, llm: Llama, system_prompt='', history=[])create_completion(self, user_prompt='')
이 연습은 강의의 일부입니다
Llama 3 다루기
연습 안내
- 미리 로드된
llm과 지정된instruction을 사용해Conversation클래스를 인스턴스화하세요. - 모델에 프롬프트를 보내 여행 추천을 받아 보세요(원하는 프롬프트를 자유롭게 사용해도 됩니다).
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
instruction = "You are a travel expert that recommends a travel destination based on a specification. Return the location name only in City, Country form."
# Define a chatbot using the Conversation class
chatbot = ____(llm, system_prompt=____)
# Send a prompt to the model
result = chatbot.____("I'd like to learn about the Aztecs.")
print(result)