Classes
ContentSource
abstract
Abstract base class for content sources.
Implementations fetch content from various origins (local…
ContentSource
abstract Abstract base class for content sources.
Implementations fetch content from various origins (local files, remote APIs, databases) and return unified ContentEntry objects.
Subclasses must implement:
- source_type property
- fetch_all() async generator
- fetch_one() async method
ABCMethods 8
source_type
property
Return source type identifier.
source_type
property def source_type(self) -> str
Return source type identifier.
Returns
String identifier like 'local', 'github', 'notion', 'rest'str
—
fetch_all
async
Fetch all content entries from this source.
fetch_all
async async def fetch_all(self) -> AsyncIterator[ContentEntry]
Fetch all content entries from this source.
Returns
AsyncIterator[ContentEntry]
fetch_one
async
Fetch a single content entry by ID.
fetch_one
async async def fetch_one(self, id: str) -> ContentEntry | None
Fetch a single content entry by ID.
Parameters 1
id |
str |
Source-specific identifier (e.g., file path, doc ID) |
Returns
ContentEntry if found, None otherwiseContentEntry | None
—
get_cache_key
Generate cache key for this source configuration.
Used to invalidate cache whe…
get_cache_key
def get_cache_key(self) -> str
Generate cache key for this source configuration.
Used to invalidate cache when config changes. Override for custom cache key logic.
Returns
16-character hex string based on config hashstr
—
get_last_modified
async
Get last modification time for the entire source.
Used for cache invalidation.…
get_last_modified
async async def get_last_modified(self) -> datetime | None
Get last modification time for the entire source.
Used for cache invalidation. Returns None if unknown or not supported.
Returns
Last modification datetime or Nonedatetime | None
—
is_changed
async
Check if source content has changed since last fetch.
is_changed
async async def is_changed(self, cached_checksum: str | None) -> bool
Check if source content has changed since last fetch.
Parameters 1
cached_checksum |
str | None |
Previously cached checksum |
Returns
True if content may have changed, False if definitely unchangedbool
—
fetch_all_sync
Synchronous wrapper for fetch_all().
Runs the async generator in a new event loop.
fetch_all_sync
def fetch_all_sync(self) -> Iterator[ContentEntry]
Synchronous wrapper for fetch_all().
Runs the async generator in a new event loop.
Returns
Iterator[ContentEntry]
fetch_one_sync
Synchronous wrapper for fetch_one().
fetch_one_sync
def fetch_one_sync(self, id: str) -> ContentEntry | None
Synchronous wrapper for fetch_one().
Parameters 1
id |
str |
Source-specific identifier |
Returns
ContentEntry if found, None otherwiseContentEntry | None
—
Internal Methods 2
__init__
Initialize content source.
__init__
def __init__(self, name: str, config: dict[str, Any]) -> None
Initialize content source.
Parameters 2
name |
str |
Unique name for this source instance (e.g., "api-docs") |
config |
dict[str, Any] |
Source-specific configuration dictionary |
__repr__
__repr__
def __repr__(self) -> str
Returns
str