mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-28 01:32:17 +00:00
Merge 06b380e813 into 2dccc0dc79
This commit is contained in:
commit
718f3204ca
2 changed files with 52 additions and 6 deletions
|
|
@ -32,8 +32,13 @@ else:
|
|||
|
||||
|
||||
class VectorStoreIndexRegistry:
|
||||
def __init__(self, vector_store_indexes: list[LiteLLM_ManagedVectorStoreIndex] = []):
|
||||
self.vector_store_indexes: list[LiteLLM_ManagedVectorStoreIndex] = vector_store_indexes
|
||||
def __init__(
|
||||
self,
|
||||
vector_store_indexes: list[LiteLLM_ManagedVectorStoreIndex] | None = None,
|
||||
):
|
||||
self.vector_store_indexes: list[LiteLLM_ManagedVectorStoreIndex] = (
|
||||
vector_store_indexes if vector_store_indexes is not None else []
|
||||
)
|
||||
|
||||
def get_vector_store_indexes(self) -> list[LiteLLM_ManagedVectorStoreIndex]:
|
||||
"""
|
||||
|
|
@ -101,8 +106,11 @@ class VectorStoreIndexRegistry:
|
|||
|
||||
|
||||
class VectorStoreRegistry:
|
||||
def __init__(self, vector_stores: list[LiteLLM_ManagedVectorStore] = []):
|
||||
self.vector_stores: list[LiteLLM_ManagedVectorStore] = vector_stores
|
||||
def __init__(
|
||||
self,
|
||||
vector_stores: list[LiteLLM_ManagedVectorStore] | None = None,
|
||||
):
|
||||
self.vector_stores: list[LiteLLM_ManagedVectorStore] = vector_stores if vector_stores is not None else []
|
||||
self.vector_store_ids_to_vector_store_map: dict[str, LiteLLM_ManagedVectorStore] = {}
|
||||
|
||||
def _extract_tool_params(self, tool: dict) -> VectorStoreToolParams:
|
||||
|
|
|
|||
|
|
@ -11,9 +11,13 @@ from datetime import datetime, timezone
|
|||
from unittest.mock import AsyncMock, MagicMock
|
||||
|
||||
import litellm
|
||||
from litellm.types.vector_stores import LiteLLM_ManagedVectorStore
|
||||
from litellm.types.vector_stores import (
|
||||
IndexCreateLiteLLMParams,
|
||||
LiteLLM_ManagedVectorStore,
|
||||
LiteLLM_ManagedVectorStoreIndex,
|
||||
)
|
||||
from litellm.vector_stores.main import search
|
||||
from litellm.vector_stores.vector_store_registry import VectorStoreRegistry
|
||||
from litellm.vector_stores.vector_store_registry import VectorStoreIndexRegistry, VectorStoreRegistry
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
|
@ -71,6 +75,40 @@ def test_get_credentials_for_vector_store():
|
|||
assert result == {}
|
||||
|
||||
|
||||
def test_vector_store_registries_do_not_share_default_list():
|
||||
first = VectorStoreRegistry()
|
||||
second = VectorStoreRegistry()
|
||||
|
||||
first.vector_stores.append(
|
||||
LiteLLM_ManagedVectorStore(
|
||||
vector_store_id="first",
|
||||
custom_llm_provider="openai",
|
||||
created_at=datetime.now(timezone.utc),
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
)
|
||||
)
|
||||
|
||||
assert second.vector_stores == []
|
||||
|
||||
|
||||
def test_vector_store_index_registries_do_not_share_default_list():
|
||||
first = VectorStoreIndexRegistry()
|
||||
second = VectorStoreIndexRegistry()
|
||||
|
||||
first.vector_store_indexes.append(
|
||||
LiteLLM_ManagedVectorStoreIndex(
|
||||
id="first",
|
||||
index_name="first",
|
||||
litellm_params=IndexCreateLiteLLMParams(
|
||||
vector_store_index="first",
|
||||
vector_store_name="first",
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
assert second.vector_store_indexes == []
|
||||
|
||||
|
||||
def test_add_vector_store_to_registry():
|
||||
"""Test that add_vector_store_to_registry adds vector store correctly when there are pre-existing stores"""
|
||||
# Create pre-existing vector stores
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue