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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(azure): keep api-version query after vector store search path
Devin AIc03a42a9c814
diff --git a/litellm/llms/openai/vector_stores/transformation.py b/litellm/llms/openai/vector_stores/transformation.pyindex 125e5168c69..57fe5b04838 100644--- a/litellm/llms/openai/vector_stores/transformation.py+++ b/litellm/llms/openai/vector_stores/transformation.py@@ -101,7 +101,8 @@ class OpenAIVectorStoreConfig(BaseVectorStoreConfig):extra_body: dict[str, object] | None = None,) -> tuple[str, dict]:encoded_vector_store_id: Final = encode_url_path_segment(vector_store_id, field_name="vector_store_id")- url: Final = f"{api_base}/{encoded_vector_store_id}/search"+ base_url, query_separator, query_string = api_base.partition("?")+ url: Final = f"{base_url}/{encoded_vector_store_id}/search{query_separator}{query_string}"typed_request_body: Final = VectorStoreSearchRequest(query=query,filters=vector_store_search_optional_params.get("filters", None),diff --git a/tests/test_litellm/llms/azure/vector_stores/__init__.py b/tests/test_litellm/llms/azure/vector_stores/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/tests/test_litellm/llms/azure/vector_stores/test_azure_vector_stores_transformation.py b/tests/test_litellm/llms/azure/vector_stores/test_azure_vector_stores_transformation.pynew file mode 100644index 00000000000..59bec08fca6--- /dev/null+++ b/tests/test_litellm/llms/azure/vector_stores/test_azure_vector_stores_transformation.py@@ -0,0 +1,20 @@+from litellm.llms.azure.vector_stores.transformation import AzureOpenAIVectorStoreConfig+++def test_transform_search_vector_store_request_preserves_azure_query_string():+ config = AzureOpenAIVectorStoreConfig()+ api_base = config.get_complete_url(+ api_base="https://x.openai.azure.com",+ litellm_params={"api_version": "2024-10-21"},+ )++ url, _ = config.transform_search_vector_store_request(+ vector_store_id="vs_1",+ query="hello",+ vector_store_search_optional_params={},+ api_base=api_base,+ litellm_logging_obj=None,+ litellm_params={"api_version": "2024-10-21"},+ )++ assert url == "https://x.openai.azure.com/openai/vector_stores/vs_1/search?api-version=2024-10-21"diff --git a/tests/test_litellm/llms/openai/vector_stores/test_openai_vector_stores_transformation.py b/tests/test_litellm/llms/openai/vector_stores/test_openai_vector_stores_transformation.pyindex e7b1aab45b4..ea1f9e87ed8 100644--- a/tests/test_litellm/llms/openai/vector_stores/test_openai_vector_stores_transformation.py+++ b/tests/test_litellm/llms/openai/vector_stores/test_openai_vector_stores_transformation.py@@ -7,11 +7,8 @@ from litellm.types.vector_stores import (class TestOpenAIVectorStoreAPIConfig:-@pytest.mark.parametrize("metadata", [{}, None])- def test_transform_create_vector_store_request_with_metadata_empty_or_none(- self, metadata- ):+ def test_transform_create_vector_store_request_with_metadata_empty_or_none(self, metadata):"""Test transform_create_vector_store_request when metadata is None or empty dict."""@@ -24,9 +21,7 @@ class TestOpenAIVectorStoreAPIConfig:"metadata": metadata,}- url, request_body = config.transform_create_vector_store_request(- vector_store_create_params, api_base- )+ url, request_body = config.transform_create_vector_store_request(vector_store_create_params, api_base)assert url == api_baseassert request_body["name"] == "test-vector-store"@@ -50,9 +45,7 @@ class TestOpenAIVectorStoreAPIConfig:"metadata": large_metadata,}- url, request_body = config.transform_create_vector_store_request(- vector_store_create_params, api_base- )+ url, request_body = config.transform_create_vector_store_request(vector_store_create_params, api_base)assert url == api_baseassert request_body["name"] == "test-vector-store"@@ -77,8 +70,19 @@ class TestOpenAIVectorStoreAPIConfig:litellm_params={},)- assert (- url- == "https://api.openai.com/v1/vector_stores/..%2F..%2Ffiles%3Fx%3D1%23frag/search"- )+ assert url == "https://api.openai.com/v1/vector_stores/..%2F..%2Ffiles%3Fx%3D1%23frag/search"assert request_body["query"] == "hello"++ def test_transform_search_vector_store_request_preserves_query_string(self):+ config = OpenAIVectorStoreConfig()++ url, _ = config.transform_search_vector_store_request(+ vector_store_id="vs_1",+ query="hello",+ vector_store_search_optional_params={},+ api_base="https://x.openai.azure.com/openai/vector_stores?api-version=2024-10-21",+ litellm_logging_obj=None,+ litellm_params={},+ )++ assert url == "https://x.openai.azure.com/openai/vector_stores/vs_1/search?api-version=2024-10-21"