25070,provide the databricks tool prompt cache

Signed-off-by: frank <frankzye@qq.com>
This commit is contained in:
frank 2026-04-05 21:21:10 +08:00
parent d4a3a5e530
commit e2b26e4161
3 changed files with 16 additions and 2 deletions

View file

@ -227,11 +227,18 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig):
if description is not None:
function_params["description"] = cast(Union[dict, str], description)
return DatabricksTool(
databricks_tool = DatabricksTool(
type="function",
function=function_params,
)
if tool.get("cache_control"):
databricks_tool["cache_control"] = cast(dict, tool.get("cache_control"))
return databricks_tool
def _map_openai_to_dbrx_tool(self, model: str, tools: List) -> List[DatabricksTool]:
# if not claude, send as is
if "claude" not in model:

View file

@ -57,9 +57,10 @@ class DatabricksFunction(TypedDict, total=False):
strict: bool
class DatabricksTool(TypedDict):
class DatabricksTool(TypedDict, total=False):
function: DatabricksFunction
type: Literal["function"]
cache_control: Optional[dict]
class DatabricksMessage(TypedDict, total=False):

View file

@ -123,6 +123,12 @@ def test_convert_anthropic_tool_to_databricks_tool_without_description():
assert databricks_tool is not None
assert databricks_tool["type"] == "function"
assert databricks_tool["function"].get("description") is None
assert "cache_control" not in databricks_tool
anthropic_tool["cache_control"] = {"type": "ephemeral"}
databricks_tool = config.convert_anthropic_tool_to_databricks_tool(anthropic_tool)
assert databricks_tool is not None
assert databricks_tool.get("cache_control") == {"type": "ephemeral"}
def test_transform_choices_with_citations():