mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-01 16:24:44 +00:00
Reverted the change in handling the case of no chunks found.
This commit is contained in:
parent
82b485b177
commit
57e28b5b9b
2 changed files with 2 additions and 16 deletions
|
@ -129,7 +129,7 @@ class MemoryToolRuntimeImpl(ToolsProtocolPrivate, ToolRuntime, RAGToolRuntime):
|
|||
scores = [s for r in results for s in r.scores]
|
||||
|
||||
if not chunks:
|
||||
raise ValueError("The knowledge search tool did not find any information relevant to the query.")
|
||||
return RAGQueryResult(content=None)
|
||||
|
||||
# sort by score
|
||||
chunks, scores = zip(*sorted(zip(chunks, scores, strict=False), key=lambda x: x[1], reverse=True), strict=False) # type: ignore
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from llama_stack.apis.vector_io import QueryChunksResponse
|
||||
from llama_stack.providers.inline.tool_runtime.rag.memory import MemoryToolRuntimeImpl
|
||||
|
||||
|
||||
|
@ -18,16 +17,3 @@ class TestRagQuery:
|
|||
rag_tool = MemoryToolRuntimeImpl(config=MagicMock(), vector_io_api=MagicMock(), inference_api=MagicMock())
|
||||
with pytest.raises(ValueError):
|
||||
await rag_tool.query(content=MagicMock(), vector_db_ids=[])
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_query_raises_on_no_chunks_found(self):
|
||||
vector_io_api = MagicMock()
|
||||
vector_io_api.query_chunks = AsyncMock(return_value=QueryChunksResponse(chunks=[], scores=[]))
|
||||
|
||||
rag_tool = MemoryToolRuntimeImpl(
|
||||
config=MagicMock(),
|
||||
vector_io_api=vector_io_api,
|
||||
inference_api=MagicMock(),
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await rag_tool.query(content=MagicMock(), vector_db_ids=["test_db"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue