Spaces:
Sleeping
Sleeping
Download app/api/notes.py from bichnhan2701/NoteServicesAPI: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/bichnhan2701/NoteServicesAPI/resolve/a6d62e8094de02c47b7e59f39cbed0c667009156/app/api/notes.py
- Command line
-
hf download hf://spaces/bichnhan2701/NoteServicesAPI@a6d62e8094de02c47b7e59f39cbed0c667009156/app/api/notes.py
-
curl -L -o notes.py https://huggingface.co/spaces/bichnhan2701/NoteServicesAPI/resolve/a6d62e8094de02c47b7e59f39cbed0c667009156/app/api/notes.py
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] = [] | |
| 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"} | |
| def fetch_note(note_id: str): | |
| note = get_note(note_id) | |
| if not note: | |
| raise HTTPException(404, "Note not found") | |
| return note | |