Files
fastapi/app/tasks/knowledge_ingestion_tasks.py
T

14 lines
531 B
Python
Raw Normal View History

import asyncio
from app.db.session import SessionLocal
from app.services.document_ingestion_service import DocumentIngestionService
from app.tasks.celery_app import celery_app
@celery_app.task(name="knowledge.ingest_document")
def ingest_knowledge_document(document_id: int, task_id: int) -> None:
"""知识库异步任务:在 Celery worker 中执行 PDF 解析和向量入库。"""
with SessionLocal() as db:
asyncio.run(DocumentIngestionService(db).ingest_document(document_id, task_id))
db.commit()