校對文字
手邊有想校對的文字嗎?使用 Databricks SDK 請 AI 模型幫你校對。它會回傳校對後的文字版本,以及一份它所做出具體修改的清單。
本練習屬於課程
使用 Python SDK 的 Databricks
練習說明
- 在 workspace client 中查詢可用來呼叫 AI 模型的類別。
- 填入用來提供 AI 模型「如何回應後續查詢」指示的角色。
- 填入在把查詢送給 AI 模型時使用的角色。
- 印出 AI 模型回應中的訊息詳細內容。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
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 AI model via the workspace client
response = w.____.query(
name="databricks-meta-llama-3-3-70b-instruct",
messages=[
ChatMessage(
# Specify the role for configuring model behavior
role=ChatMessageRole.____, content=f"You are a helpful writing assistant. "
),
ChatMessage(
# Specify the role for sending the query
role=ChatMessageRole.____, content=f"Proofread the following text: {text_to_proofread}"
),
],
max_tokens=200)
# Print the content of the model's response
print(f"RESPONSE:\n{response.choices[0].message.____}")