始める無料で始める

テキストの校正

校正したいテキストがありますか?Databricks SDK を使って、AIモデルにテキストの校正を依頼しましょう。AIモデルは、校正済みのテキストと、加えた変更点のリストを返してくれます。

この演習はコースの一部です

Databricks と Python SDK

コースを見る

演習の手順

  • ワークスペースクライアント内で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.____}")
コードを編集して実行