Skip to content

Commit 6a47ac1

Browse files
Merge pull request #13886 from frankzye/feature/databricks-function-call-missing-pass-description
pass function tool description for databricks provider
2 parents 53bf023 + a80cfe5 commit 6a47ac1

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

litellm/llms/databricks/chat/transformation.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,17 @@ def convert_anthropic_tool_to_databricks_tool(
169169
if tool is None:
170170
return None
171171

172+
kwags = {
173+
"name":tool["name"],
174+
"parameters":cast(dict, tool.get("input_schema") or {})
175+
}
176+
177+
if tool.get("description"):
178+
kwags["description"] = tool.get("description")
179+
172180
return DatabricksTool(
173181
type="function",
174-
function=DatabricksFunction(
175-
name=tool["name"],
176-
parameters=cast(dict, tool.get("input_schema") or {}),
177-
),
182+
function=DatabricksFunction(**kwags),
178183
)
179184

180185
def _map_openai_to_dbrx_tool(self, model: str, tools: List) -> List[DatabricksTool]:

litellm/types/llms/databricks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class DatabricksReasoningContent(TypedDict, total=False):
5151

5252
class DatabricksFunction(TypedDict, total=False):
5353
name: Required[str]
54-
description: dict
54+
description: dict | str
5555
parameters: dict
5656
strict: bool
5757

tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,33 @@ def test_transform_choices_without_signature():
9494
assert thinking_block["type"] == "thinking"
9595
assert thinking_block["thinking"] == "i'm thinking without signature."
9696

97+
def test_convert_anthropic_tool_to_databricks_tool_with_description():
98+
config = DatabricksConfig()
99+
anthropic_tool = {
100+
"name": "test_tool",
101+
"description": "test description",
102+
"input_schema": {"type": "object", "properties": {"test": {"type": "string"}}}
103+
}
104+
105+
databricks_tool = config.convert_anthropic_tool_to_databricks_tool(anthropic_tool)
106+
107+
assert databricks_tool is not None
108+
assert databricks_tool["type"] == "function"
109+
assert databricks_tool["function"]["description"] == "test description"
110+
111+
112+
def test_convert_anthropic_tool_to_databricks_tool_without_description():
113+
config = DatabricksConfig()
114+
anthropic_tool = {
115+
"name": "test_tool",
116+
"input_schema": {"type": "object", "properties": {"test": {"type": "string"}}}
117+
}
118+
119+
databricks_tool = config.convert_anthropic_tool_to_databricks_tool(anthropic_tool)
120+
121+
assert databricks_tool is not None
122+
assert databricks_tool["type"] == "function"
123+
assert databricks_tool["function"].get("description") is None
97124

98125
def test_transform_choices_with_citations():
99126
config = DatabricksConfig()

0 commit comments

Comments
 (0)