Skip to content

Commit 472397b

Browse files
are-cesclaude
andcommitted
LCORE-1426: remove redundant max_chunks param and rename _fetch_solr_rag to _fetch_okp_rag
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e581fa5 commit 472397b

2 files changed

Lines changed: 9 additions & 16 deletions

File tree

src/utils/vector_search.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ async def _fetch_byok_rag( # pylint: disable=too-many-locals
443443
client: AsyncLlamaStackClient,
444444
query: str,
445445
vector_store_ids: Optional[list[str]] = None,
446-
max_chunks: Optional[int] = None,
447446
) -> tuple[list[RAGChunk], list[ReferencedDocument]]:
448447
"""Fetch chunks and documents from BYOK RAG sources.
449448
@@ -453,15 +452,13 @@ async def _fetch_byok_rag( # pylint: disable=too-many-locals
453452
vector_store_ids: Optional list of vector store IDs to query.
454453
If provided, only these stores will be queried. If None, all stores
455454
(excluding Solr) will be queried.
456-
max_chunks: Maximum number of chunks to return. If None, uses
457-
rag.byok.max_chunks from configuration.
458455
459456
Returns:
460457
Tuple containing:
461458
- rag_chunks: RAG chunks from BYOK RAG
462459
- referenced_documents: Documents referenced in BYOK RAG results
463460
"""
464-
limit = max_chunks if max_chunks is not None else configuration.rag.byok.max_chunks
461+
limit = configuration.rag.byok.max_chunks
465462
rag_chunks: list[RAGChunk] = []
466463
referenced_documents: list[ReferencedDocument] = []
467464

@@ -550,7 +547,7 @@ async def _fetch_byok_rag( # pylint: disable=too-many-locals
550547
return rag_chunks, referenced_documents
551548

552549

553-
async def _fetch_solr_rag( # pylint: disable=too-many-locals
550+
async def _fetch_okp_rag( # pylint: disable=too-many-locals
554551
client: AsyncLlamaStackClient,
555552
query: str,
556553
solr: Optional[SolrVectorSearchRequest] = None,
@@ -561,8 +558,6 @@ async def _fetch_solr_rag( # pylint: disable=too-many-locals
561558
client: The AsyncLlamaStackClient to use for the request
562559
query: The user's query
563560
solr: Structured Solr inline RAG request from the API (optional).
564-
max_chunks: Maximum number of chunks to return. If None, uses
565-
rag.okp.max_chunks from configuration.
566561
567562
Returns:
568563
Tuple containing:
@@ -658,10 +653,8 @@ async def build_rag_context( # pylint: disable=too-many-locals,too-many-branche
658653
top_k = configuration.rag.retrieval.inline.max_chunks
659654

660655
# Fetch from each source using per-source limits for the reranking pool
661-
byok_chunks_task = _fetch_byok_rag(
662-
client, query, vector_store_ids, max_chunks=configuration.rag.byok.max_chunks
663-
)
664-
solr_chunks_task = _fetch_solr_rag(client, query, solr)
656+
byok_chunks_task = _fetch_byok_rag(client, query, vector_store_ids)
657+
solr_chunks_task = _fetch_okp_rag(client, query, solr)
665658

666659
(byok_chunks, byok_documents), (solr_chunks, solr_documents) = await asyncio.gather(
667660
byok_chunks_task, solr_chunks_task

tests/unit/utils/test_vector_search.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
_extract_byok_rag_chunks,
2323
_extract_solr_document_metadata,
2424
_fetch_byok_rag,
25-
_fetch_solr_rag,
25+
_fetch_okp_rag,
2626
_format_rag_context,
2727
_get_okp_base_url,
2828
_get_solr_vector_store_ids,
@@ -703,7 +703,7 @@ async def test_request_id_not_in_inline_config_skips_byok(
703703

704704

705705
class TestFetchSolrRag:
706-
"""Tests for _fetch_solr_rag async function."""
706+
"""Tests for _fetch_okp_rag async function."""
707707

708708
@pytest.mark.asyncio
709709
async def test_solr_disabled(self, mocker: MockerFixture) -> None:
@@ -713,7 +713,7 @@ async def test_solr_disabled(self, mocker: MockerFixture) -> None:
713713
mocker.patch("utils.vector_search.configuration", config_mock)
714714

715715
client_mock = mocker.AsyncMock()
716-
rag_chunks, referenced_docs = await _fetch_solr_rag(client_mock, "test query")
716+
rag_chunks, referenced_docs = await _fetch_okp_rag(client_mock, "test query")
717717

718718
assert rag_chunks == []
719719
assert referenced_docs == []
@@ -745,7 +745,7 @@ async def test_solr_enabled_success(self, mocker: MockerFixture) -> None:
745745
client_mock = mocker.AsyncMock()
746746
client_mock.vector_io.query.return_value = query_response
747747

748-
rag_chunks, _referenced_docs = await _fetch_solr_rag(client_mock, "test query")
748+
rag_chunks, _referenced_docs = await _fetch_okp_rag(client_mock, "test query")
749749

750750
assert len(rag_chunks) > 0
751751
assert rag_chunks[0].content == "Solr content"
@@ -775,7 +775,7 @@ async def test_solr_enabled_passes_request_mode_to_vector_io(
775775
client_mock = mocker.AsyncMock()
776776
client_mock.vector_io.query.return_value = query_response
777777

778-
await _fetch_solr_rag(
778+
await _fetch_okp_rag(
779779
client_mock,
780780
"test query",
781781
SolrVectorSearchRequest(mode="semantic", filters={"fq": ["x:y"]}),

0 commit comments

Comments
 (0)