mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
25070,provide the databricks tool prompt cache
Signed-off-by: frank <frankzye@qq.com>
This commit is contained in:
parent
d4a3a5e530
commit
e2b26e4161
3 changed files with 16 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue