Skip to content

OSSS.ai.agents.historian.search

OSSS.ai.agents.historian.search

Historical search infrastructure for the Historian agent.

This module provides various search strategies for finding relevant historical content from the notes directory, including tag-based, keyword, and future semantic search capabilities.

SearchResult

Bases: BaseModel

A single search result from historical content.

Migrated from dataclass to Pydantic BaseModel for enhanced validation, serialization, and integration with the OSSS Pydantic ecosystem.

uuid property

Get UUID from metadata if available.

topics property

Get topics from metadata.

domain property

Get domain from metadata.

HistorianSearchInterface

Bases: ABC

Abstract interface for historical search strategies.

search(query, limit=10) abstractmethod async

Search for relevant historical content.

Parameters

query : str The search query limit : int Maximum number of results to return

Returns

List[SearchResult] Ranked list of search results

NotesDirectoryParser

Utility class for parsing markdown notes with frontmatter.

parse_note(filepath)

Parse a markdown note and extract frontmatter and content.

Returns

Dict[str, Any] or None Dictionary with 'frontmatter' and 'content' keys, or None if parsing fails

get_all_notes()

Get all parseable notes from the directory.

Returns

List[Tuple[str, Dict[str, Any]]] List of (filepath, parsed_note) tuples

TagBasedSearch

Bases: HistorianSearchInterface

Search based on frontmatter topics and tags.

search(query, limit=10) async

Search based on topic matching.

KeywordSearch

Bases: HistorianSearchInterface

Enhanced keyword search with TF-IDF-like scoring.

search(query, limit=10) async

Search based on keyword matching with relevance scoring.

HybridSearch

Bases: HistorianSearchInterface

Hybrid search combining tag-based and keyword search.

search(query, limit=10) async

Combine results from tag-based and keyword search.

SemanticSearchPlaceholder

Bases: HistorianSearchInterface

Placeholder for future semantic search implementation.

search(query, limit=10) async

Placeholder that falls back to hybrid search.

SearchFactory

Factory for creating different types of search instances.

Create a search instance.

Parameters

search_type : str Type of search: "tag", "keyword", "hybrid", "semantic" notes_directory : str, optional Directory containing notes (defaults to config)

Returns

HistorianSearchInterface Search instance