Cli accepts filter
This commit is contained in:
parent
7d57fd6c97
commit
f3565afdf7
2 changed files with 9 additions and 3 deletions
|
|
@ -192,9 +192,9 @@ class HaikuRAGApp:
|
||||||
f"[yellow]Document with id {doc_id} not found.[/yellow]"
|
f"[yellow]Document with id {doc_id} not found.[/yellow]"
|
||||||
)
|
)
|
||||||
|
|
||||||
async def search(self, query: str, limit: int = 5):
|
async def search(self, query: str, limit: int = 5, filter: str | None = None):
|
||||||
async with HaikuRAG(db_path=self.db_path) as self.client:
|
async with HaikuRAG(db_path=self.db_path) as self.client:
|
||||||
results = await self.client.search(query, limit=limit)
|
results = await self.client.search(query, limit=limit, filter=filter)
|
||||||
if not results:
|
if not results:
|
||||||
self.console.print("[yellow]No results found.[/yellow]")
|
self.console.print("[yellow]No results found.[/yellow]")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,12 @@ def search(
|
||||||
"-l",
|
"-l",
|
||||||
help="Maximum number of results to return",
|
help="Maximum number of results to return",
|
||||||
),
|
),
|
||||||
|
filter: str | None = typer.Option(
|
||||||
|
None,
|
||||||
|
"--filter",
|
||||||
|
"-f",
|
||||||
|
help="SQL WHERE clause to filter documents (e.g., \"uri LIKE '%arxiv%'\")",
|
||||||
|
),
|
||||||
db: Path = typer.Option(
|
db: Path = typer.Option(
|
||||||
Config.storage.data_dir / "haiku.rag.lancedb",
|
Config.storage.data_dir / "haiku.rag.lancedb",
|
||||||
"--db",
|
"--db",
|
||||||
|
|
@ -230,7 +236,7 @@ def search(
|
||||||
from haiku.rag.app import HaikuRAGApp
|
from haiku.rag.app import HaikuRAGApp
|
||||||
|
|
||||||
app = HaikuRAGApp(db_path=db)
|
app = HaikuRAGApp(db_path=db)
|
||||||
asyncio.run(app.search(query=query, limit=limit))
|
asyncio.run(app.search(query=query, limit=limit, filter=filter))
|
||||||
|
|
||||||
|
|
||||||
@cli.command("ask", help="Ask a question using the QA agent")
|
@cli.command("ask", help="Ask a question using the QA agent")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue