ComenzarEmpieza gratis

Text summarization

Want to turn a poem into a quick summary? Let’s make it happen! You have the full text of a poem stored as a string variable called raven_text, which you will hand off to a Chat AI model and ask it to summarize the poem in a set number of words.

Este ejercicio forma parte del curso

Databricks with the Python SDK

Ver curso

Instrucciones del ejercicio

  • Ask the AI agent to summarize the poem "The Raven" by Edgar Allan Poe.
  • Define the model name as Meta Llama 3, already saved as ai_model.
  • Create the message you want to send to the AI model, including the raven_text variable.
  • Use the chat message role used to query the AI model.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

w = WorkspaceClient()

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

# Ask the AI agent to summarize the poem "The Raven" by Edgar Allan Poe
response = w.serving_endpoints.query(
  # Define the model name as meta llama 3
  name=____,  
  messages=[
    	# Create the message you want to send to the AI agent
        ____(
          	# Use the chat message role used to query the AI agent
            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}")
Editar y ejecutar código