bichnhan2701's picture
Debug
2faaa56
raw
history blame
1.09 kB
from fastapi import APIRouter, BackgroundTasks, HTTPException
from pydantic import BaseModel
from typing import Optional, List
from app.services.storage import create_note as storage_create_note, get_note
from app.jobs.enrichment_job import run_enrichment
router = APIRouter(prefix="/notes")
class CreateNoteRequest(BaseModel):
note_id: str
raw_text: str
normalized_text: Optional[str] = None
keywords: List[str] = []
chunks: list = []
duration: Optional[float] = None
sample_rate: Optional[int] = None
asr_model: Optional[str] = None
normalization_model: Optional[str] = None
generate: List[str] = []
@router.post("")
async def create_note(req: CreateNoteRequest, bg: BackgroundTasks):
storage_create_note(req.note_id, req.dict())
if req.generate:
bg.add_task(run_enrichment, req.note_id, req.generate)
return {"note_id": req.note_id, "status": "stored"}
@router.get("/{note_id}")
def fetch_note(note_id: str):
note = get_note(note_id)
if not note:
raise HTTPException(404, "Note not found")
return note