A source represents an embedded text passage
| 18 | |
| 19 | |
| 20 | class Source(SqlalchemyBase, OrganizationMixin): |
| 21 | """A source represents an embedded text passage""" |
| 22 | |
| 23 | __tablename__ = "sources" |
| 24 | __pydantic_model__ = PydanticSource |
| 25 | |
| 26 | __table_args__ = ( |
| 27 | Index(f"source_created_at_id_idx", "created_at", "id"), |
| 28 | {"extend_existing": True}, |
| 29 | ) |
| 30 | |
| 31 | name: Mapped[str] = mapped_column(doc="the name of the source, must be unique within the org", nullable=False) |
| 32 | description: Mapped[str] = mapped_column(nullable=True, doc="a human-readable description of the source") |
| 33 | embedding_config: Mapped[EmbeddingConfig] = mapped_column(EmbeddingConfigColumn, doc="Configuration settings for embedding.") |
| 34 | metadata_: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True, doc="metadata for the source.") |
| 35 | |
| 36 | # relationships |
| 37 | organization: Mapped["Organization"] = relationship("Organization", back_populates="sources") |
| 38 | files: Mapped[List["FileMetadata"]] = relationship("FileMetadata", back_populates="source", cascade="all, delete-orphan") |
| 39 | passages: Mapped[List["SourcePassage"]] = relationship("SourcePassage", back_populates="source", cascade="all, delete-orphan") |
| 40 | agents: Mapped[List["Agent"]] = relationship( |
| 41 | "Agent", |
| 42 | secondary="sources_agents", |
| 43 | back_populates="sources", |
| 44 | lazy="selectin", |
| 45 | cascade="save-update", # Only propagate save and update operations |
| 46 | passive_deletes=True, # Let the database handle deletions |
| 47 | ) |
no outgoing calls
no test coverage detected