Spaces:
Running
Running
File size: 1,091 Bytes
0785301 2faaa56 0785301 2faaa56 0785301 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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
|