vlsiddarth's picture
Commit latest version with ranking logic and API fixes
0733aae
"""
Knowledge Universe — JSON Format Adapter
Standard JSON output — default for AI system consumption.
"""
from typing import Any, Dict
from src.api.models import Source
from src.format_adapters.base_adapter import BaseFormatAdapter
class JSONFormatAdapter(BaseFormatAdapter):
"""
Returns source as a clean JSON-serializable dictionary.
Datetime fields are converted to ISO strings.
Enum fields are converted to their string values.
"""
def transform(self, source: Source) -> Dict[str, Any]:
return source.model_dump(mode="json")
def transform_many(self, sources: list) -> list:
return [self.transform(s) for s in sources]