Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Merge branch 'main' into feature/databricks-function-call-missing-pass-description

Krish Dholakiaa80cfe5fb548
diff --cc tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py
index 55ab4428617,51a2e971c09..a14683fac17
--- a/tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py
+++ b/tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py
@@@ -91,30 -94,95 +94,122 @@@ def test_transform_choices_without_sign
assert thinking_block["type"] == "thinking"
assert thinking_block["thinking"] == "i'm thinking without signature."
+def test_convert_anthropic_tool_to_databricks_tool_with_description():
+ config = DatabricksConfig()
+ anthropic_tool = {
+ "name": "test_tool",
+ "description": "test description",
+ "input_schema": {"type": "object", "properties": {"test": {"type": "string"}}}
+ }
+
+ databricks_tool = config.convert_anthropic_tool_to_databricks_tool(anthropic_tool)
+
+ assert databricks_tool is not None
+ assert databricks_tool["type"] == "function"
+ assert databricks_tool["function"]["description"] == "test description"
+
+
+def test_convert_anthropic_tool_to_databricks_tool_without_description():
+ config = DatabricksConfig()
+ anthropic_tool = {
+ "name": "test_tool",
+ "input_schema": {"type": "object", "properties": {"test": {"type": "string"}}}
+ }
+
+ databricks_tool = config.convert_anthropic_tool_to_databricks_tool(anthropic_tool)
+
+ assert databricks_tool is not None
+ assert databricks_tool["type"] == "function"
- assert databricks_tool["function"].get("description") is None
++ assert databricks_tool["function"].get("description") is None
+
+ def test_transform_choices_with_citations():
+ config = DatabricksConfig()
+ databricks_choices = [
+ {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "type": "text",
+ "text": "Blue",
+ "citations": [
+ {
+ "type": "char_location",
+ "cited_text": "The sky is blue.",
+ "document_index": 0,
+ "document_title": "My Document",
+ "start_char_index": 0,
+ "end_char_index": 50,
+ }
+ ],
+ }
+ ],
+ },
+ "index": 0,
+ "finish_reason": "stop",
+ }
+ ]
+
+ choices = config._transform_dbrx_choices(choices=databricks_choices)
+
+ assert choices[0].message.provider_specific_fields == {
+ "citations": [
+ [
+ {
+ "type": "char_location",
+ "cited_text": "The sky is blue.",
+ "document_index": 0,
+ "document_title": "My Document",
+ "start_char_index": 0,
+ "end_char_index": 50,
+ "supported_text": "Blue",
+ }
+ ]
+ ]
+ }
+
+
+ def test_chunk_parser_with_citation():
+ iterator = DatabricksChatResponseIterator(None, sync_stream=True)
+ chunk = {
+ "id": "1",
+ "object": "chat.completion.chunk",
+ "created": 0,
+ "model": "test",
+ "choices": [
+ {
+ "delta": {
+ "content": [
+ {
+ "type": "text",
+ "text": "",
+ "citations": [
+ {
+ "type": "char_location",
+ "cited_text": "The sky is blue.",
+ "document_index": 0,
+ "document_title": "My Document",
+ "start_char_index": 0,
+ "end_char_index": 50,
+ }
+ ],
+ }
+ ],
+ },
+ "index": 0,
+ "finish_reason": None,
+ }
+ ],
+ }
+
+ parsed = iterator.chunk_parser(chunk)
+ assert parsed.choices[0].delta.provider_specific_fields == {
+ "citation": {
+ "type": "char_location",
+ "cited_text": "The sky is blue.",
+ "document_index": 0,
+ "document_title": "My Document",
+ "start_char_index": 0,
+ "end_char_index": 50,
+ }
+ }