시작하기무료로 시작하기

다중 턴 대화

여행 챗봇을 확장해서, 사용자가 모델의 초기 추천에 답변할 수 있도록 만들어 봅시다. 이번에도 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)
코드 편집 및 실행