The app manages multiple life areas (health, finance, personal, work), not just health. Updated all health-specific language throughout: Backend: - Default system prompt: general personal assistant (not health-only) - AI tool descriptions: generic (not health records/medications) - Memory categories: health, finance, personal, work, document_summary, other (replaces condition, medication, allergy, vital) - PDF template: "Prepared for" (not "Patient"), "Key Information" (not "Health Profile") - Renamed generate_health_pdf -> generate_pdf_report, health_report.html -> report.html - Renamed run_daily_health_review -> run_daily_review - Context assembly: "User Profile" (not "Health Profile") - OpenAPI: generic descriptions Frontend: - Dashboard subtitle: "Your personal AI assistant" - Memory categories: Health, Finance, Personal, Work - Document types: Report, Contract, Receipt, Certificate (not lab_result, etc.) - Updated en + ru translations throughout Documentation: - README: general personal assistant description - Removed health-only feature descriptions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
import uuid
|
|
from pathlib import Path
|
|
from typing import Annotated
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from fastapi.responses import FileResponse
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.api.deps import get_current_user
|
|
from app.database import get_db
|
|
from app.models.user import User
|
|
from app.schemas.pdf import GeneratePdfRequest, PdfListResponse, PdfResponse
|
|
from app.services import pdf_service
|
|
|
|
router = APIRouter(prefix="/pdf", tags=["pdf"])
|
|
|
|
|
|
@router.post("/compile", response_model=PdfResponse, status_code=status.HTTP_201_CREATED)
|
|
async def compile_pdf(
|
|
data: GeneratePdfRequest,
|
|
user: Annotated[User, Depends(get_current_user)],
|
|
db: Annotated[AsyncSession, Depends(get_db)],
|
|
):
|
|
pdf = await pdf_service.generate_pdf_report(
|
|
db, user.id, data.title, data.document_ids or None, data.chat_id,
|
|
)
|
|
return PdfResponse.model_validate(pdf)
|
|
|
|
|
|
@router.get("/", response_model=PdfListResponse)
|
|
async def list_pdfs(
|
|
user: Annotated[User, Depends(get_current_user)],
|
|
db: Annotated[AsyncSession, Depends(get_db)],
|
|
):
|
|
pdfs = await pdf_service.get_user_pdfs(db, user.id)
|
|
return PdfListResponse(pdfs=[PdfResponse.model_validate(p) for p in pdfs])
|
|
|
|
|
|
@router.get("/{pdf_id}/download")
|
|
async def download_pdf(
|
|
pdf_id: uuid.UUID,
|
|
user: Annotated[User, Depends(get_current_user)],
|
|
db: Annotated[AsyncSession, Depends(get_db)],
|
|
):
|
|
pdf = await pdf_service.get_pdf(db, pdf_id, user.id)
|
|
if not pdf:
|
|
raise HTTPException(status_code=404, detail="PDF not found")
|
|
file_path = Path(pdf.storage_path)
|
|
if not file_path.exists():
|
|
raise HTTPException(status_code=404, detail="PDF file not found on disk")
|
|
media_type = "application/pdf" if file_path.suffix == ".pdf" else "text/html"
|
|
return FileResponse(path=str(file_path), filename=f"{pdf.title}.pdf", media_type=media_type)
|