<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to invoke Databricks AI Assistant from a notebook cell? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-invoke-databricks-ai-assistant-from-a-notebook-cell/m-p/133395#M49829</link>
    <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/121720"&gt;@shashankB&lt;/a&gt;&amp;nbsp;There are no command like %assistant exists today to interact with Databricks Assistant. As&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/110502"&gt;@szymon_dybczak&lt;/a&gt;&amp;nbsp;mentioned in the reply&amp;nbsp; the exiting modes that you can interact with Assistant today.&lt;/P&gt;&lt;P&gt;Also there is no published Assistant‑specific REST API in the Databricks today. But you can built your own custom assistant in notebooks using&amp;nbsp;Model Serving / Foundation Models endpoints.&lt;/P&gt;&lt;P&gt;Here are few examples.&lt;/P&gt;&lt;P&gt;1. Using Model Serving:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Databricks notebook (Python)
from databricks.sdk import WorkspaceClient

# Get OpenAI-compatible client for your workspace serving endpoints
w = WorkspaceClient()
client = w.serving_endpoints.get_open_ai_client()

code_to_review = """[Put your code here]"""

prompt = f"""You are a senior Databricks reviewer.
Identify bugs, performance issues, and style problems in this code.
Return a short bullet list with actionable fixes, and a corrected snippet.
Code:{code_to_review}"""

system_msg = (
        "You are a senior Databricks code reviewer. "
        "Focus on correctness, Spark/Delta best practices, performance, security/secrets handling, "
        "cluster/UC implications, and style. "
        "Return Markdown with three sections: "
        "1) Findings (bullets), 2) Proposed fixes (bullets), 3) Revised code (single fenced block)."
    )


resp = client.chat.completions.create(
        model="databricks-meta-llama-3-3-70b-instruct",
        messages=[
            {"role": "system", "content": system_msg},
            {"role": "user", "content": prompt},
        ],
        temperature=0.1,
        max_tokens=900,
    )
print(resp.choices[0].message.content)&lt;/LI-CODE&gt;&lt;P&gt;2. Use SQL AI functions:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;%sql

SELECT ai_query(
  "databricks-meta-llama-3-3-70b-instruct",
  "Review this PySpark code for correctness and performance. " ||
  "Suggest changes if needed:\n\n" ||
  :code_text  -- pass as SQL variable that holds the code text
) AS review;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Sep 2025 17:25:39 GMT</pubDate>
    <dc:creator>nayan_wylde</dc:creator>
    <dc:date>2025-09-30T17:25:39Z</dc:date>
    <item>
      <title>How to invoke Databricks AI Assistant from a notebook cell?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-invoke-databricks-ai-assistant-from-a-notebook-cell/m-p/133377#M49822</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;&lt;P&gt;I am exploring the Databricks AI Assistant and wondering if there is a way to invoke or interact with it directly from a notebook cell instead of using the workspace sidebar UI.&lt;/P&gt;&lt;P&gt;Is there any built-in command (like %assistant) to open or trigger the Assistant inside notebooks?&lt;/P&gt;&lt;P&gt;If not, what is the recommended way to mimic the Assistant’s functionality programmatically? For example, can we send prompts and get responses inside notebooks?&lt;/P&gt;&lt;P&gt;I often upload notebooks from my local system into Databricks, and I would like the AI Assistant to review or analyze the uploaded code before I actually run it.&lt;/P&gt;&lt;P&gt;Any official documentation or examples would also be very helpful.&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2025 12:37:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-invoke-databricks-ai-assistant-from-a-notebook-cell/m-p/133377#M49822</guid>
      <dc:creator>shashankB</dc:creator>
      <dc:date>2025-09-30T12:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to invoke Databricks AI Assistant from a notebook cell?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-invoke-databricks-ai-assistant-from-a-notebook-cell/m-p/133379#M49823</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/121720"&gt;@shashankB&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Here's a good documentation of all possible interaction with an assistant:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/notebooks/databricks-assistant-faq" target="_blank" rel="noopener"&gt;What is Databricks Assistant? | Databricks on AWS&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Basically, is supports various modes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://docs.databricks.com/aws/en/notebooks/use-databricks-assistant#chat-pane" target="_blank" rel="noopener"&gt;Chat mode&lt;/A&gt;: Get answers to your questions by chatting with the Assistant. It responds with relevant information, including citations from Databricks documentation.&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://docs.databricks.com/aws/en/notebooks/code-assistant#edit-mode-for-suggestions-across-multiple-notebook-cells" target="_blank" rel="noopener"&gt;Edit mode&lt;/A&gt;: Allow the Assistant to make suggestions across multiple cells in your notebook from a single prompt.&lt;/LI&gt;&lt;LI&gt;Agent mode: Use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/notebooks/ds-agent" target="_blank" rel="noopener"&gt;Data Science Agent (Beta)&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to automate entire multi-step data science workflows in notebooks and the SQL editor.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;And you can use shortcut commands to interact with agent:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/notebooks/code-assistant#assistant-command-shortcuts-for-notebooks" target="_blank" rel="noopener"&gt;Get coding help from Databricks Assistant | Databricks on AWS&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="szymon_dybczak_0-1759236213011.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20316i07AD102E0A0BF34D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="szymon_dybczak_0-1759236213011.png" alt="szymon_dybczak_0-1759236213011.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, to answer your question in title. Here what you can do:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="szymon_dybczak_0-1759236643109.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20317iD27151F925BC67BF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="szymon_dybczak_0-1759236643109.png" alt="szymon_dybczak_0-1759236643109.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2025 12:51:13 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-invoke-databricks-ai-assistant-from-a-notebook-cell/m-p/133379#M49823</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2025-09-30T12:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to invoke Databricks AI Assistant from a notebook cell?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-invoke-databricks-ai-assistant-from-a-notebook-cell/m-p/133395#M49829</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/121720"&gt;@shashankB&lt;/a&gt;&amp;nbsp;There are no command like %assistant exists today to interact with Databricks Assistant. As&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/110502"&gt;@szymon_dybczak&lt;/a&gt;&amp;nbsp;mentioned in the reply&amp;nbsp; the exiting modes that you can interact with Assistant today.&lt;/P&gt;&lt;P&gt;Also there is no published Assistant‑specific REST API in the Databricks today. But you can built your own custom assistant in notebooks using&amp;nbsp;Model Serving / Foundation Models endpoints.&lt;/P&gt;&lt;P&gt;Here are few examples.&lt;/P&gt;&lt;P&gt;1. Using Model Serving:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Databricks notebook (Python)
from databricks.sdk import WorkspaceClient

# Get OpenAI-compatible client for your workspace serving endpoints
w = WorkspaceClient()
client = w.serving_endpoints.get_open_ai_client()

code_to_review = """[Put your code here]"""

prompt = f"""You are a senior Databricks reviewer.
Identify bugs, performance issues, and style problems in this code.
Return a short bullet list with actionable fixes, and a corrected snippet.
Code:{code_to_review}"""

system_msg = (
        "You are a senior Databricks code reviewer. "
        "Focus on correctness, Spark/Delta best practices, performance, security/secrets handling, "
        "cluster/UC implications, and style. "
        "Return Markdown with three sections: "
        "1) Findings (bullets), 2) Proposed fixes (bullets), 3) Revised code (single fenced block)."
    )


resp = client.chat.completions.create(
        model="databricks-meta-llama-3-3-70b-instruct",
        messages=[
            {"role": "system", "content": system_msg},
            {"role": "user", "content": prompt},
        ],
        temperature=0.1,
        max_tokens=900,
    )
print(resp.choices[0].message.content)&lt;/LI-CODE&gt;&lt;P&gt;2. Use SQL AI functions:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;%sql

SELECT ai_query(
  "databricks-meta-llama-3-3-70b-instruct",
  "Review this PySpark code for correctness and performance. " ||
  "Suggest changes if needed:\n\n" ||
  :code_text  -- pass as SQL variable that holds the code text
) AS review;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2025 17:25:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-invoke-databricks-ai-assistant-from-a-notebook-cell/m-p/133395#M49829</guid>
      <dc:creator>nayan_wylde</dc:creator>
      <dc:date>2025-09-30T17:25:39Z</dc:date>
    </item>
  </channel>
</rss>

