Files
furyhawk bb4b614711 feat: Implement RAG document and sync services with vector store integration
- Added `vectorstore.py` for managing vector storage operations using Milvus.
- Introduced `rag_document.py` for handling RAG document lifecycle, including ingestion and status updates.
- Created `rag_status.py` for streaming RAG ingestion status via Redis pub/sub.
- Developed `rag_sync.py` for managing synchronization operations and logs.
- Implemented `sync_source.py` for managing sync source configurations and triggering syncs.
- Established a lightweight task dispatcher in `dispatcher.py` for background task execution.
- Registered task functions for RAG ingestion and sync operations in `rag_tasks.py`.
- Configured task dispatcher settings in `arq_settings.py`.
- Added necessary database models and schemas for RAG document and sync operations.
2026-06-13 21:52:27 +08:00

57 lines
1.8 KiB
Python

"""Sync source ORM model."""
from __future__ import annotations
import uuid
from datetime import datetime, timezone
from sqlalchemy import Boolean, DateTime, Integer, String, Text
from sqlalchemy.dialects.postgresql import JSON, UUID
from sqlalchemy.orm import Mapped, mapped_column
from backend.core.models import Base
class SyncSource(Base):
"""Configuration for a RAG sync source (local folder, GDrive, S3, etc.)."""
__tablename__ = "sync_sources"
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), primary_key=True, default=uuid.uuid4
)
name: Mapped[str] = mapped_column(String(255), nullable=False)
connector_type: Mapped[str] = mapped_column(
String(50), nullable=False
)
collection_name: Mapped[str] = mapped_column(
String(255), nullable=False, default="documents"
)
config: Mapped[dict | None] = mapped_column(JSON, nullable=True, default=None)
sync_mode: Mapped[str] = mapped_column(
String(20), nullable=False, default="full"
)
schedule_minutes: Mapped[int | None] = mapped_column(
Integer, nullable=True, default=None
)
is_active: Mapped[bool] = mapped_column(
Boolean, nullable=False, default=True
)
last_sync_at: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True), nullable=True, default=None
)
last_sync_status: Mapped[str | None] = mapped_column(
String(20), nullable=True, default=None
)
last_error: Mapped[str | None] = mapped_column(
Text, nullable=True, default=None
)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
default=lambda: datetime.now(timezone.utc),
)
def __repr__(self) -> str:
return f"<SyncSource {self.name!r} type={self.connector_type!r}>"