feat: add streaming learning assistant and knowledge base scaffolding
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""异步任务模块:生产环境通过 Celery worker 执行耗时任务。"""
|
||||
@@ -0,0 +1,16 @@
|
||||
from celery import Celery
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
celery_app = Celery(
|
||||
"medical_agent",
|
||||
broker=settings.celery_broker_url,
|
||||
backend=settings.celery_result_backend,
|
||||
)
|
||||
celery_app.conf.update(
|
||||
task_serializer="json",
|
||||
accept_content=["json"],
|
||||
result_serializer="json",
|
||||
timezone="Asia/Shanghai",
|
||||
enable_utc=False,
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user