CommencerCommencer gratuitement

Proofreading text

Have text that you want to proofread? Use the Databricks SDK to ask an AI model to proofread your text for you. It will send you back the proofread version of your text and a list of the specific changes it made.

Cet exercice fait partie du cours

Databricks with the Python SDK

Afficher le cours

Instructions

  • Query the class in the workspace client used to query AI models.
  • Fill in the role used to provide instructions to the AI model on how to answer future queries.
  • Fill in the role used when sending a query to the AI model.
  • Print the message details from the AI model response.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

w = WorkspaceClient()
text_to_proofread = "I am gong to the stor to buy some bred. I migt also buy some mlk. Do u want to jon me?"

# Query the class in the workspace client used to query AI models
response = w.____.query(
  name="databricks-meta-llama-3-3-70b-instruct",
  messages=[
        ChatMessage( # Fill in the roles used to provide instructions to the AI model on how to answer future queries
            role=ChatMessageRole.____, content=f"You are a helpful writing assistant. "
        ),
        ChatMessage( # Fill in the role used when sending a query to the AI model
            role=ChatMessageRole.____, content=f"Proofread the following text: {text_to_proofread}"
        ),
    ],
  max_tokens=200)

# Print the message details from the AI model response
print(f"RESPONSE:\n{response.choices[0].message.____}")
Modifier et exécuter le code