from praisonaiagents.knowledge.readers import Document, get_reader_registry
from typing import List, Dict, Any, Optional
class MyCustomReader:
name = "custom"
supported_extensions = ["custom", "cst"]
def load(
self,
source: str,
metadata: Optional[Dict[str, Any]] = None,
**kwargs
) -> List[Document]:
with open(source, 'r') as f:
content = f.read()
return [Document(
text=content,
metadata={"source": source, **(metadata or {})}
)]
# Register the reader
registry = get_reader_registry()
registry.register(MyCustomReader())