文本校对
有需要校对的文本吗?使用 Databricks SDK 请求 AI 模型为您校对文本。它会返回校对后的版本,以及它所做的具体修改列表。
本练习是课程的一部分
使用 Python SDK 的 Databricks
练习说明
- 在 workspace 客户端中查询用于调用 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.____}")