System 메시지
이전 메시지들은 유효한 응답을 받았지만, 인터넷 서비스 지원과 무관한 질문도 사용자에게 허용하고 있어요. 이 연습 문제에서는 system 메시지를 사용해 모델이 인터넷 서비스에 관한 고객 문의에만 답하도록 유도해 보겠습니다.
Llama 모델은 여전히 llm으로 사용할 수 있어요.
이 연습은 강의의 일부입니다
Llama 3 다루기
연습 안내
- 제공된 메시지 딕셔너리에
"system"역할을 추가하고, 이를conv리스트에 넣으세요. result객체에서 모델 응답인"message"를 추출하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Add a system message to the conversation list
conv = [
{
"role": "____",
"content": "You are a helpful and professional customer support assistant for an internet service provider. If the question or instruction doesn't relate to internet service, quote the response: 'Sorry, I can't answer that.'"},
{
"role": "user",
"content": "Help me decide which stocks to invest in."
}
]
result = llm.create_chat_completion(messages=conv, max_tokens=15)
# Extract the model response from the result object
assistant_content = result["choices"][0]["____"]["content"]
print(assistant_content)