fix skill list_documents tool ignores state.document_filter
This commit is contained in:
parent
4c1eec4ae7
commit
99af4fe11d
4 changed files with 25 additions and 3 deletions
|
|
@ -6,6 +6,10 @@
|
||||||
- **S3/Object storage support**: Connect to LanceDB on S3, GCS, Azure Blob, or HDFS via `lancedb.uri` and `storage_options` config. Supports S3-compatible stores with custom endpoints.
|
- **S3/Object storage support**: Connect to LanceDB on S3, GCS, Azure Blob, or HDFS via `lancedb.uri` and `storage_options` config. Supports S3-compatible stores with custom endpoints.
|
||||||
- **Remote skill generation**: `create-skill` now supports remote databases — omit `--db` and provide `--config-file` to generate skills that connect to object storage at runtime instead of bundling the database.
|
- **Remote skill generation**: `create-skill` now supports remote databases — omit `--db` and provide `--config-file` to generate skills that connect to object storage at runtime instead of bundling the database.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Skill `list_documents` ignores `document_filter`**: `list_documents` tool now respects `state.document_filter`, consistent with `search`, `ask`, and `research`
|
||||||
|
|
||||||
## [0.38.0] - 2026-04-07
|
## [0.38.0] - 2026-04-07
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class RAGState(BaseModel):
|
||||||
|
|
||||||
- **citations** — Accumulated citations from `ask` calls, with sequential indexing across calls.
|
- **citations** — Accumulated citations from `ask` calls, with sequential indexing across calls.
|
||||||
- **qa_history** — Questions and answers from `ask` calls. Prior Q&A is used as context for follow-up questions when embeddings are similar.
|
- **qa_history** — Questions and answers from `ask` calls. Prior Q&A is used as context for follow-up questions when embeddings are similar.
|
||||||
- **document_filter** — SQL WHERE clause applied to `search`, `ask`, and `research` calls. Set this to scope queries to specific documents.
|
- **document_filter** — SQL WHERE clause applied to `search`, `list_documents`, `ask`, and `research` calls. Set this to scope queries to specific documents.
|
||||||
- **searches** — Search results keyed by query string.
|
- **searches** — Search results keyed by query string.
|
||||||
- **documents** — Documents seen via `list_documents` or `get_document` (deduplicated by ID).
|
- **documents** — Documents seen via `list_documents` or `get_document` (deduplicated by ID).
|
||||||
- **reports** — Research reports from `research` calls.
|
- **reports** — Research reports from `research` calls.
|
||||||
|
|
|
||||||
|
|
@ -90,11 +90,12 @@ async def skill_list_documents(
|
||||||
config: AppConfig,
|
config: AppConfig,
|
||||||
limit: int | None = None,
|
limit: int | None = None,
|
||||||
offset: int | None = None,
|
offset: int | None = None,
|
||||||
|
filter: str | None = None,
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, Any]]:
|
||||||
from haiku.rag.client import HaikuRAG
|
from haiku.rag.client import HaikuRAG
|
||||||
|
|
||||||
async with HaikuRAG(db_path, config=config, read_only=True) as rag:
|
async with HaikuRAG(db_path, config=config, read_only=True) as rag:
|
||||||
documents = await rag.list_documents(limit, offset)
|
documents = await rag.list_documents(limit, offset, filter=filter)
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"id": doc.id,
|
"id": doc.id,
|
||||||
|
|
@ -350,8 +351,14 @@ def create_skill_tools(
|
||||||
limit: Maximum number of documents to return.
|
limit: Maximum number of documents to return.
|
||||||
offset: Number of documents to skip.
|
offset: Number of documents to skip.
|
||||||
"""
|
"""
|
||||||
result = await skill_list_documents(db_path, config, limit, offset)
|
|
||||||
state = _get_state(ctx, state_type)
|
state = _get_state(ctx, state_type)
|
||||||
|
result = await skill_list_documents(
|
||||||
|
db_path,
|
||||||
|
config,
|
||||||
|
limit,
|
||||||
|
offset,
|
||||||
|
filter=state.document_filter if state else None,
|
||||||
|
)
|
||||||
if state:
|
if state:
|
||||||
update_documents_state(state.documents, result)
|
update_documents_state(state.documents, result)
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
|
|
@ -276,6 +276,17 @@ class TestListDocumentsTool:
|
||||||
assert isinstance(state.documents[0], DocumentInfo)
|
assert isinstance(state.documents[0], DocumentInfo)
|
||||||
assert state.documents[0].id is not None
|
assert state.documents[0].id is not None
|
||||||
|
|
||||||
|
async def test_list_documents_applies_document_filter_from_state(self, rag_db):
|
||||||
|
from haiku.rag.skills.rag import RAGState, create_skill
|
||||||
|
|
||||||
|
skill = create_skill(db_path=rag_db)
|
||||||
|
list_docs = _get_tool(skill, "list_documents")
|
||||||
|
state = RAGState(document_filter="title = 'AI Overview'")
|
||||||
|
ctx = _make_ctx(state)
|
||||||
|
results = await list_docs(ctx)
|
||||||
|
assert len(results) == 1
|
||||||
|
assert results[0]["title"] == "AI Overview"
|
||||||
|
|
||||||
async def test_list_documents_no_duplicates_in_state(self, rag_db):
|
async def test_list_documents_no_duplicates_in_state(self, rag_db):
|
||||||
from haiku.rag.skills.rag import RAGState, create_skill
|
from haiku.rag.skills.rag import RAGState, create_skill
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue