from fastapi import APIRouter, HTTPException from fastapi.responses import HTMLResponse from agents.books.reference_lang import ( run_references, ) router = APIRouter(prefix="/book", tags=["Books"]) @router.post("/reference") async def process_book( book_json: dict , ): try: if not book_json: raise HTTPException(status_code=400, detail="لا توجد بيانات مرسلة") html_content = run_references(book_json) return HTMLResponse(content=html_content, status_code=200) except HTTPException: raise except Exception as e: raise HTTPException(status_code=500, detail=f"خطأ في التحويل: {str(e)}")