38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from datetime import datetime
|
|
from pathlib import Path
|
|
|
|
|
|
def run_chat(
|
|
db_path: Path | None = None,
|
|
read_only: bool = False,
|
|
before: datetime | None = None,
|
|
background_context: str | None = None,
|
|
) -> None:
|
|
"""Run the chat TUI.
|
|
|
|
Args:
|
|
db_path: Path to the LanceDB database. If None, uses default from config.
|
|
read_only: Whether to open the database in read-only mode.
|
|
before: Query database as it existed before this datetime.
|
|
background_context: Optional background context for the conversation.
|
|
"""
|
|
try:
|
|
from haiku.rag.chat.app import ChatApp
|
|
except ImportError as e: # pragma: no cover
|
|
raise ImportError(
|
|
"textual is not installed. Please install it with `pip install 'haiku.rag-slim[tui]'` or use the full haiku.rag package."
|
|
) from e
|
|
|
|
from haiku.rag.config import get_config
|
|
|
|
config = get_config()
|
|
if db_path is None:
|
|
db_path = config.storage.data_dir / "haiku.rag.lancedb"
|
|
|
|
app = ChatApp(
|
|
db_path,
|
|
read_only=read_only,
|
|
before=before,
|
|
background_context=background_context,
|
|
)
|
|
app.run()
|