chore: init monorepo snapshot
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from app.schemas.job import JobCreate, JobResponse, JobStatus
|
||||
from app.services.runtime import job_store, worker
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/ingest", response_model=JobResponse)
|
||||
async def ingest(job: JobCreate) -> JobResponse:
|
||||
"""创建一次全量 ingest 任务并入队"""
|
||||
created = await worker.enqueue(
|
||||
notebook_id=job.notebook_id,
|
||||
doc_id=job.doc_id,
|
||||
source=job.source,
|
||||
blocks=job.blocks or [],
|
||||
)
|
||||
return JobResponse(job=JobStatus(**created.__dict__))
|
||||
|
||||
|
||||
@router.post("/ingest/incremental", response_model=JobResponse)
|
||||
async def ingest_incremental(job: JobCreate) -> JobResponse:
|
||||
"""增量模式目前与全量逻辑一致,后续通过 checkpoint 提升效率"""
|
||||
created = await worker.enqueue(
|
||||
notebook_id=job.notebook_id,
|
||||
doc_id=job.doc_id,
|
||||
source=job.source,
|
||||
blocks=job.blocks or [],
|
||||
)
|
||||
return JobResponse(job=JobStatus(**created.__dict__))
|
||||
|
||||
|
||||
@router.get("/jobs/{job_id}", response_model=JobResponse)
|
||||
async def get_job(job_id: str) -> JobResponse:
|
||||
job = await job_store.get(job_id)
|
||||
if not job:
|
||||
raise HTTPException(status_code=404, detail="Job not found")
|
||||
return JobResponse(job=JobStatus(**job.__dict__))
|
||||
Reference in New Issue
Block a user