Skip to content

Searcher

obsidian_palace.search.searcher

MemPalace search wrapper.

Provides a simplified interface to MemPalace's semantic search capabilities, configured against the Obsidian vault's ChromaDB persistence directory.

MemPalace is entirely synchronous — all calls are wrapped with asyncio.to_thread to avoid blocking the FastAPI event loop.

logger = logging.getLogger(__name__) module-attribute

SearchResult dataclass

A single search result from MemPalace.

content: str instance-attribute

source_path: str instance-attribute

score: float instance-attribute

metadata: dict = field(default_factory=dict) class-attribute instance-attribute

__init__(content: str, source_path: str, score: float, metadata: dict = dict()) -> None

search(query: str, limit: int = 10) -> list[SearchResult] async

Search the vault index using MemPalace semantic search.

Wraps the synchronous MemPalace search_memories call in asyncio.to_thread so it does not block the event loop.

Parameters:

Name Type Description Default
query str

Natural language search query.

required
limit int

Maximum number of results.

10

Returns:

Type Description
list[SearchResult]

Ranked list of search results.