Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
### Internal Changes

### API Changes

- extra fields in the FoundationModel class
35 changes: 35 additions & 0 deletions databricks/sdk/service/serving.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,55 @@ def test_serde_with_empty_dataclass():
)
assert inst.as_dict() == {"pipeline_id": "123", "run_continuously": {}}
assert inst == catalog.OnlineTableSpec.from_dict(inst.as_dict())


def test_foundation_model_serde():
from databricks.sdk.service.serving import FoundationModel

model = FoundationModel(
name="system.ai.databricks-claude-sonnet-4-5",
display_name="Claude Sonnet 4.5",
docs="https://docs.databricks.com/machine-learning/foundation-models/supported-models.html#claude-sonnet-4-5",
description="Claude Sonnet 4.5 is Anthropic's most advanced hybrid reasoning model. It offers two modes: near-instant responses and extended thinking for deeper reasoning based on the complexity of the task. Claude Sonnet 4.5 specializes in application that require a balance of practical throughput and advanced thinking such as customer-facing agents, production coding workflows, and content generation at scale. This endpoint is hosted by Databricks",
price="214.286",
input_price="85.714",
price_unit="DBUs per 1M tokens",
pricing_model="Pay-per-token",
model_class="claude",
)

expected = {
"name": "system.ai.databricks-claude-sonnet-4-5",
"display_name": "Claude Sonnet 4.5",
"docs": "https://docs.databricks.com/machine-learning/foundation-models/supported-models.html#claude-sonnet-4-5",
"description": "Claude Sonnet 4.5 is Anthropic's most advanced hybrid reasoning model. It offers two modes: near-instant responses and extended thinking for deeper reasoning based on the complexity of the task. Claude Sonnet 4.5 specializes in application that require a balance of practical throughput and advanced thinking such as customer-facing agents, production coding workflows, and content generation at scale. This endpoint is hosted by Databricks",
"price": "214.286",
"input_price": "85.714",
"price_unit": "DBUs per 1M tokens",
"pricing_model": "Pay-per-token",
"model_class": "claude",
}

assert model.as_dict() == expected
assert model.as_shallow_dict() == expected
assert model == FoundationModel.from_dict(model.as_dict())


def test_foundation_model_serde_partial():
from databricks.sdk.service.serving import FoundationModel

model = FoundationModel(
name="system.ai.databricks-claude-sonnet-4-5",
price="214.286",
model_class="claude",
)

expected = {
"name": "system.ai.databricks-claude-sonnet-4-5",
"price": "214.286",
"model_class": "claude",
}

assert model.as_dict() == expected
assert model.as_shallow_dict() == expected
assert model == FoundationModel.from_dict(model.as_dict())