Skip to main content
  • Sync
  • Async
def ingest_text(
    content: str,
    filename: Optional[str] = None,
    metadata: Optional[Dict[str, Any]] = None,
    use_colpali: bool = True,
) -> Document

Parameters

  • content (str): Text content to ingest
  • filename (str, optional): Optional filename for the document
  • metadata (Dict[str, Any], optional): Optional metadata dictionary
  • use_colpali (bool, optional): Whether to use ColPali-style embedding model to ingest the text (slower, but significantly better retrieval accuracy for text and images). Defaults to True.

Typed Metadata

Pass native Python types for metadata (e.g., datetime, date, Decimal, bool). The SDK normalizes them, forwards the appropriate metadata_types, and unlocks range queries described in the Metadata Filtering guide. Example:
from datetime import datetime, date
from decimal import Decimal

doc = db.ingest_text(
    "SOW details …",
    metadata={
        "priority": 42,
        "start_date": datetime.utcnow(),
        "end_date": date(2024, 12, 31),
        "cost": Decimal("1234.56")
    }
)

Returns

  • Document: Metadata of the ingested document

Examples

  • Sync
  • Async
from morphik import Morphik

db = Morphik()

doc = db.ingest_text(
    "Machine learning is fascinating...",
    metadata={"category": "tech"},
    use_colpali=True,
)