Databricks with the Python SDK
Avi Steinberg
Senior Software Engineer

Hosted outside of Databricks:


Hosted on Databricks:
$$



serving_endpoints attribute of the WorkspaceClientSYSTEM:
Instructions for how model should respond to queries
USER:
Queries sent to the model by the user
Example prompt:
"You are a helpful python coding assistant."
Example prompt:
"How do for loops work in Python?"
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.serving import ChatMessage, ChatMessageRole
w = WorkspaceClient()
response = w.serving_endpoints.query(
name="databricks-meta-llama-3-3-70b-instruct",
messages=[
ChatMessage(
role=ChatMessageRole.SYSTEM, content="You are a helpful assistant."
),
ChatMessage(role=ChatMessageRole.USER, content="<your-question>"),
],
max_tokens=128)
print(f"RESPONSE:\n{response.choices[0].message.content}")
Databricks with the Python SDK