Skip to content

Commit 8fb26da

Browse files
committed
Move query and streaming_query to vector_stores
1 parent 4f39c33 commit 8fb26da

4 files changed

Lines changed: 60 additions & 36 deletions

File tree

src/app/endpoints/query.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,10 @@ async def retrieve_response( # pylint: disable=too-many-locals,too-many-branche
732732
),
733733
}
734734

735-
vector_db_ids = [
736-
vector_db.identifier for vector_db in await client.vector_dbs.list()
735+
vector_store_ids = [
736+
vector_store.id for vector_store in (await client.vector_stores.list()).data
737737
]
738-
toolgroups = (get_rag_toolgroups(vector_db_ids) or []) + [
738+
toolgroups = (get_rag_toolgroups(vector_store_ids) or []) + [
739739
mcp_server.name for mcp_server in configuration.mcp_servers
740740
]
741741
# Convert empty list to None for consistency with existing behavior
@@ -831,30 +831,30 @@ def validate_attachments_metadata(attachments: list[Attachment]) -> None:
831831

832832

833833
def get_rag_toolgroups(
834-
vector_db_ids: list[str],
834+
vector_store_ids: list[str],
835835
) -> list[Toolgroup] | None:
836836
"""
837-
Return a list of RAG Tool groups if the given vector DB list is not empty.
837+
Return a list of RAG Tool groups if the given vector store list is not empty.
838838
839839
Generate a list containing a RAG knowledge search toolgroup if
840-
vector database IDs are provided.
840+
vector store IDs are provided.
841841
842842
Parameters:
843-
vector_db_ids (list[str]): List of vector database identifiers to include in the toolgroup.
843+
vector_store_ids (list[str]): List of vector store identifiers to include in the toolgroup.
844844
845845
Returns:
846846
list[Toolgroup] | None: A list with a single RAG toolgroup if
847-
vector_db_ids is non-empty; otherwise, None.
847+
vector_store_ids is non-empty; otherwise, None.
848848
"""
849849
return (
850850
[
851851
ToolgroupAgentToolGroupWithArgs(
852852
name="builtin::rag/knowledge_search",
853853
args={
854-
"vector_db_ids": vector_db_ids,
854+
"vector_store_ids": vector_store_ids,
855855
},
856856
)
857857
]
858-
if vector_db_ids
858+
if vector_store_ids
859859
else None
860860
)

src/app/endpoints/streaming_query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,10 +1031,10 @@ async def retrieve_response(
10311031
),
10321032
}
10331033

1034-
vector_db_ids = [
1035-
vector_db.identifier for vector_db in await client.vector_dbs.list()
1034+
vector_store_ids = [
1035+
vector_store.id for vector_store in (await client.vector_stores.list()).data
10361036
]
1037-
toolgroups = (get_rag_toolgroups(vector_db_ids) or []) + [
1037+
toolgroups = (get_rag_toolgroups(vector_store_ids) or []) + [
10381038
mcp_server.name for mcp_server in configuration.mcp_servers
10391039
]
10401040
# Convert empty list to None for consistency with existing behavior

tests/unit/app/endpoints/test_query.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,16 +1414,16 @@ async def test_retrieve_response_shield_violation(
14141414

14151415
def test_get_rag_toolgroups() -> None:
14161416
"""Test get_rag_toolgroups function."""
1417-
vector_db_ids: list[str] = []
1418-
result = get_rag_toolgroups(vector_db_ids)
1417+
vector_store_ids: list[str] = []
1418+
result = get_rag_toolgroups(vector_store_ids)
14191419
assert result is None
14201420

1421-
vector_db_ids = ["Vector-DB-1", "Vector-DB-2"]
1422-
result = get_rag_toolgroups(vector_db_ids)
1421+
vector_store_ids = ["Vector-DB-1", "Vector-DB-2"]
1422+
result = get_rag_toolgroups(vector_store_ids)
14231423
assert result is not None
14241424
assert len(result) == 1
14251425
assert result[0]["name"] == "builtin::rag/knowledge_search"
1426-
assert result[0]["args"]["vector_db_ids"] == vector_db_ids
1426+
assert result[0]["args"]["vector_store_ids"] == vector_store_ids
14271427

14281428

14291429
@pytest.mark.asyncio

tests/unit/app/endpoints/test_streaming_query.py

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,11 @@ async def test_retrieve_response_vector_db_available(
453453
mock_client, mock_agent = prepare_agent_mocks
454454
mock_agent.create_turn.return_value.output_message.content = "LLM answer"
455455
mock_client.shields.list.return_value = []
456-
mock_vector_db = mocker.Mock()
457-
mock_vector_db.identifier = "VectorDB-1"
458-
mock_client.vector_dbs.list.return_value = [mock_vector_db]
456+
mock_vector_store = mocker.Mock()
457+
mock_vector_store.id = "VectorDB-1"
458+
mock_list_response = mocker.Mock()
459+
mock_list_response.data = [mock_vector_store]
460+
mock_client.vector_stores.list.return_value = mock_list_response
459461

460462
# Mock configuration with empty MCP servers
461463
mock_config = mocker.Mock()
@@ -498,7 +500,9 @@ async def test_retrieve_response_no_available_shields(
498500
mock_client, mock_agent = prepare_agent_mocks
499501
mock_agent.create_turn.return_value.output_message.content = "LLM answer"
500502
mock_client.shields.list.return_value = []
501-
mock_client.vector_dbs.list.return_value = []
503+
mock_list_response = mocker.Mock()
504+
mock_list_response.data = []
505+
mock_client.vector_stores.list.return_value = mock_list_response
502506

503507
# Mock configuration with empty MCP servers
504508
mock_config = mocker.Mock()
@@ -554,7 +558,9 @@ def __repr__(self) -> str:
554558
mock_client, mock_agent = prepare_agent_mocks
555559
mock_agent.create_turn.return_value.output_message.content = "LLM answer"
556560
mock_client.shields.list.return_value = [MockShield("shield1")]
557-
mock_client.vector_dbs.list.return_value = []
561+
mock_list_response = mocker.Mock()
562+
mock_list_response.data = []
563+
mock_client.vector_stores.list.return_value = mock_list_response
558564

559565
# Mock configuration with empty MCP servers
560566
mock_config = mocker.Mock()
@@ -611,7 +617,9 @@ def __repr__(self) -> str:
611617
MockShield("shield1"),
612618
MockShield("shield2"),
613619
]
614-
mock_client.vector_dbs.list.return_value = []
620+
mock_list_response = mocker.Mock()
621+
mock_list_response.data = []
622+
mock_client.vector_stores.list.return_value = mock_list_response
615623

616624
# Mock configuration with empty MCP servers
617625
mock_config = mocker.Mock()
@@ -670,7 +678,9 @@ def __repr__(self) -> str:
670678
MockShield("output_shield3"),
671679
MockShield("inout_shield4"),
672680
]
673-
mock_client.vector_dbs.list.return_value = []
681+
mock_list_response = mocker.Mock()
682+
mock_list_response.data = []
683+
mock_client.vector_stores.list.return_value = mock_list_response
674684

675685
# Mock configuration with empty MCP servers
676686
mock_config = mocker.Mock()
@@ -723,7 +733,9 @@ async def test_retrieve_response_with_one_attachment(
723733
mock_client, mock_agent = prepare_agent_mocks
724734
mock_agent.create_turn.return_value.output_message.content = "LLM answer"
725735
mock_client.shields.list.return_value = []
726-
mock_client.vector_dbs.list.return_value = []
736+
mock_list_response = mocker.Mock()
737+
mock_list_response.data = []
738+
mock_client.vector_stores.list.return_value = mock_list_response
727739

728740
# Mock configuration with empty MCP servers
729741
mock_config = mocker.Mock()
@@ -777,7 +789,9 @@ async def test_retrieve_response_with_two_attachments(
777789
mock_client, mock_agent = prepare_agent_mocks
778790
mock_agent.create_turn.return_value.output_message.content = "LLM answer"
779791
mock_client.shields.list.return_value = []
780-
mock_client.vector_dbs.list.return_value = []
792+
mock_list_response = mocker.Mock()
793+
mock_list_response.data = []
794+
mock_client.vector_stores.list.return_value = mock_list_response
781795

782796
# Mock configuration with empty MCP servers
783797
mock_config = mocker.Mock()
@@ -1188,7 +1202,9 @@ async def test_retrieve_response_with_mcp_servers(
11881202
mock_client, mock_agent = prepare_agent_mocks
11891203
mock_agent.create_turn.return_value.output_message.content = "LLM answer"
11901204
mock_client.shields.list.return_value = []
1191-
mock_client.vector_dbs.list.return_value = []
1205+
mock_list_response = mocker.Mock()
1206+
mock_list_response.data = []
1207+
mock_client.vector_stores.list.return_value = mock_list_response
11921208

11931209
# Mock configuration with MCP servers
11941210
mcp_servers = [
@@ -1267,7 +1283,9 @@ async def test_retrieve_response_with_mcp_servers_empty_token(
12671283
mock_client, mock_agent = prepare_agent_mocks
12681284
mock_agent.create_turn.return_value.output_message.content = "LLM answer"
12691285
mock_client.shields.list.return_value = []
1270-
mock_client.vector_dbs.list.return_value = []
1286+
mock_list_response = mocker.Mock()
1287+
mock_list_response.data = []
1288+
mock_client.vector_stores.list.return_value = mock_list_response
12711289

12721290
# Mock configuration with MCP servers
12731291
mcp_servers = [
@@ -1331,7 +1349,9 @@ async def test_retrieve_response_with_mcp_servers_and_mcp_headers(
13311349
mock_agent.create_turn.return_value.output_message.content = "LLM answer"
13321350
mock_client = mocker.AsyncMock()
13331351
mock_client.shields.list.return_value = []
1334-
mock_client.vector_dbs.list.return_value = []
1352+
mock_list_response = mocker.Mock()
1353+
mock_list_response.data = []
1354+
mock_client.vector_stores.list.return_value = mock_list_response
13351355

13361356
# Mock configuration with MCP servers
13371357
mcp_servers = [
@@ -1587,9 +1607,11 @@ async def test_retrieve_response_no_tools_bypasses_mcp_and_rag(
15871607
mock_client, mock_agent = prepare_agent_mocks
15881608
mock_agent.create_turn.return_value.output_message.content = "LLM answer"
15891609
mock_client.shields.list.return_value = []
1590-
mock_vector_db = mocker.Mock()
1591-
mock_vector_db.identifier = "VectorDB-1"
1592-
mock_client.vector_dbs.list.return_value = [mock_vector_db]
1610+
mock_vector_store = mocker.Mock()
1611+
mock_vector_store.id = "VectorDB-1"
1612+
mock_list_response = mocker.Mock()
1613+
mock_list_response.data = [mock_vector_store]
1614+
mock_client.vector_stores.list.return_value = mock_list_response
15931615

15941616
# Mock configuration with MCP servers
15951617
mcp_servers = [
@@ -1637,9 +1659,11 @@ async def test_retrieve_response_no_tools_false_preserves_functionality(
16371659
mock_client, mock_agent = prepare_agent_mocks
16381660
mock_agent.create_turn.return_value.output_message.content = "LLM answer"
16391661
mock_client.shields.list.return_value = []
1640-
mock_vector_db = mocker.Mock()
1641-
mock_vector_db.identifier = "VectorDB-1"
1642-
mock_client.vector_dbs.list.return_value = [mock_vector_db]
1662+
mock_vector_store = mocker.Mock()
1663+
mock_vector_store.id = "VectorDB-1"
1664+
mock_list_response = mocker.Mock()
1665+
mock_list_response.data = [mock_vector_store]
1666+
mock_client.vector_stores.list.return_value = mock_list_response
16431667

16441668
# Mock configuration with MCP servers
16451669
mcp_servers = [

0 commit comments

Comments
 (0)