제품 리뷰를 위한 퓨샷 프롬프팅
여러분은 전자상거래 플랫폼 BrightCart에서 일하고 있습니다. 제품 페이지에는 수천 개의 고객 리뷰를 짧은 핵심 인사이트로 압축하는 AI "Quick-Read" 배지가 표시됩니다. 인사이트를 더욱 간결하게 전달하기 위해, 요약을 두 문장으로 나눌 예정입니다. 첫 번째 문장에는 가장 눈에 띄는 긍정적인 점을, 두 번째 문장에는 솔직한 우려 사항을 담습니다.
퓨샷 프롬프팅을 통해 Claude에게 이 형식을 학습시켜, 앞으로 모든 제품에 동일한 균형 잡힌 요약이 생성되도록 해 보세요.
anthropic 라이브러리, client, raw_review 샘플은 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
Claude 모델 입문
연습 안내
- Claude의 첫 번째 예시 응답에 맞는 올바른 역할을 설정하세요.
- 해당 제품에 대한 2문장 요약 작성을 요청하세요.
- 완성된
messages배열을 API 호출에 전달하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
messages = [
{"role": "user", "content": "Summarize: Nice phone, fast performance, great camera. Screen scratches easily though."},
# Set the role for Claude's first example response
{"role": ____, "content": "Fast performance and excellent camera make this phone stand out. However, the screen may be prone to scratching."},
{"role": "user", "content": "Summarize: Comfortable shoes, good for walking. Run small, order size up."},
# Write a 2-sentence summary following the established pattern
{"role": "assistant", "content": ____},
{"role": "user", "content": f"Summarize: {raw_review}"}]
# Pass the complete messages array to the API call
response = client.messages.create(
model="claude-sonnet-4-6", max_tokens=75,
messages=____)
print(response.content[0].text)