시작하기무료로 시작하기

텍스트 요약

시를 간결한 요약문으로 바꾸고 싶으신가요? 직접 해봅시다! raven_text라는 문자열 변수에 시 전문이 저장되어 있습니다. 이 텍스트를 Chat AI 모델에 전달하여 지정한 단어 수로 시를 요약하도록 요청할 것입니다.

이 연습은 강의의 일부입니다

Python SDK로 Databricks 다루기

강의 보기

연습 안내

  • AI 에이전트에게 Edgar Allan Poe의 시 "The Raven"을 요약하도록 요청하세요.
  • 모델 이름을 Meta Llama 3으로 지정하세요. 이미 ai_model로 저장되어 있습니다.
  • AI 모델에 전송할 메시지를 생성하고, raven_text 변수를 포함하세요.
  • AI 모델에 쿼리할 때 사용하는 채팅 메시지 역할을 적용하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

w = WorkspaceClient()

ai_model = "databricks-meta-llama-3-3-70b-instruct"

# Summarize the poem
response = w.serving_endpoints.query(
  # Set model name
  name=____,  
  messages=[
    	# Create a chat message to send to the model
        ____(
          	# Specify the role for sending the query
            role=ChatMessageRole.____, content=f"Summarize this poem by Edgar Allan Poe: {____} in 3 bullet points"
        ),
    ],
  max_tokens=200)

print(f"RESPONSE:\n{response.choices[0].message.content}")
코드 편집 및 실행