diff --git a/servers/fastapi/api/v1/ppt/endpoints/images.py b/servers/fastapi/api/v1/ppt/endpoints/images.py index cd5b123a..62731f5a 100644 --- a/servers/fastapi/api/v1/ppt/endpoints/images.py +++ b/servers/fastapi/api/v1/ppt/endpoints/images.py @@ -86,7 +86,7 @@ async def get_uploaded_images(sql_session: AsyncSession = Depends(get_async_sess ) -@IMAGES_ROUTER.delete("/{id}") +@IMAGES_ROUTER.delete("/{id}", status_code=204) async def delete_uploaded_image_by_id( id: uuid.UUID, sql_session: AsyncSession = Depends(get_async_session) ): diff --git a/servers/fastapi/api/v1/ppt/endpoints/presentation.py b/servers/fastapi/api/v1/ppt/endpoints/presentation.py index 63ea2d5c..9b7a1ae7 100644 --- a/servers/fastapi/api/v1/ppt/endpoints/presentation.py +++ b/servers/fastapi/api/v1/ppt/endpoints/presentation.py @@ -11,10 +11,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from sqlmodel import select from models.generate_presentation_request import GeneratePresentationRequest from models.presentation_and_path import PresentationPathAndEditPath -from models.presentation_from_template import ( - EditPresentationRequest, - GetPresentationUsingTemplateRequest, -) +from models.presentation_from_template import EditPresentationRequest from models.presentation_outline_model import ( PresentationOutlineModel, SlideOutlineModel, @@ -29,7 +26,6 @@ from models.presentation_with_slides import ( ) from services.documents_loader import DocumentsLoader -from services.score_based_chunker import ScoreBasedChunker from utils.get_layout_by_name import get_layout_by_name from services.image_generation_service import ImageGenerationService from utils.dict_utils import deep_update diff --git a/servers/fastapi/models/presentation_with_slides.py b/servers/fastapi/models/presentation_with_slides.py index d91ca305..3a4d83b4 100644 --- a/servers/fastapi/models/presentation_with_slides.py +++ b/servers/fastapi/models/presentation_with_slides.py @@ -9,7 +9,6 @@ from models.sql.slide import SlideModel class PresentationWithSlides(BaseModel): id: uuid.UUID - user: uuid.UUID content: str n_slides: int language: str diff --git a/servers/nextjs/app/(presentation-generator)/outline/hooks/useOutlineStreaming.ts b/servers/nextjs/app/(presentation-generator)/outline/hooks/useOutlineStreaming.ts index 3f3f1057..edbcbb6c 100644 --- a/servers/nextjs/app/(presentation-generator)/outline/hooks/useOutlineStreaming.ts +++ b/servers/nextjs/app/(presentation-generator)/outline/hooks/useOutlineStreaming.ts @@ -29,7 +29,7 @@ export const useOutlineStreaming = (presentationId: string | null) => { setIsLoading(true) try { eventSource = new EventSource( - `/api/v1/ppt/outlines/stream?presentation_id=${presentationId}` + `/api/v1/ppt/outlines/stream/${presentationId}` ); eventSource.addEventListener("response", (event) => { @@ -42,7 +42,7 @@ export const useOutlineStreaming = (presentationId: string | null) => { try { const repairedJson = jsonrepair(accumulatedChunks); const partialData = JSON.parse(repairedJson); - + if (partialData.slides) { const nextSlides: { content: string }[] = partialData.slides || []; // Determine which slide index changed to minimize live parsing @@ -70,7 +70,7 @@ export const useOutlineStreaming = (presentationId: string | null) => { highestIndexRef.current = nextActive; setHighestActiveIndex(nextActive); } - } catch {} + } catch { } prevSlidesRef.current = nextSlides; dispatch(setOutlines(nextSlides)); @@ -82,18 +82,18 @@ export const useOutlineStreaming = (presentationId: string | null) => { break; case "complete": - + try { const outlinesData: { content: string }[] = data.presentation.outlines.slides; dispatch(setOutlines(outlinesData)); - setIsStreaming(false) - setIsLoading(false) - setActiveSlideIndex(null) - setHighestActiveIndex(-1) - prevSlidesRef.current = outlinesData; - activeIndexRef.current = -1; - highestIndexRef.current = -1; - eventSource.close(); + setIsStreaming(false) + setIsLoading(false) + setActiveSlideIndex(null) + setHighestActiveIndex(-1) + prevSlidesRef.current = outlinesData; + activeIndexRef.current = -1; + highestIndexRef.current = -1; + eventSource.close(); } catch (error) { console.error("Error parsing accumulated chunks:", error); toast.error("Failed to parse presentation data"); @@ -103,7 +103,7 @@ export const useOutlineStreaming = (presentationId: string | null) => { break; case "closing": - + setIsStreaming(false) setIsLoading(false) setActiveSlideIndex(null) @@ -113,7 +113,7 @@ export const useOutlineStreaming = (presentationId: string | null) => { eventSource.close(); break; case "error": - + setIsStreaming(false) setIsLoading(false) setActiveSlideIndex(null) @@ -131,7 +131,7 @@ export const useOutlineStreaming = (presentationId: string | null) => { }); eventSource.onerror = () => { - + setIsStreaming(false) setIsLoading(false) setActiveSlideIndex(null) @@ -142,7 +142,7 @@ export const useOutlineStreaming = (presentationId: string | null) => { toast.error("Failed to connect to the server. Please try again."); }; } catch (error) { - + setIsStreaming(false) setIsLoading(false) setActiveSlideIndex(null) diff --git a/servers/nextjs/app/(presentation-generator)/presentation/hooks/usePresentationStreaming.ts b/servers/nextjs/app/(presentation-generator)/presentation/hooks/usePresentationStreaming.ts index 887a1da8..aafc7a5e 100644 --- a/servers/nextjs/app/(presentation-generator)/presentation/hooks/usePresentationStreaming.ts +++ b/servers/nextjs/app/(presentation-generator)/presentation/hooks/usePresentationStreaming.ts @@ -30,7 +30,7 @@ export const usePresentationStreaming = ( trackEvent(MixpanelEvent.Presentation_Stream_API_Call); eventSource = new EventSource( - `/api/v1/ppt/presentation/stream?presentation_id=${presentationId}` + `/api/v1/ppt/presentation/stream/${presentationId}` ); eventSource.addEventListener("response", (event) => { diff --git a/servers/nextjs/app/(presentation-generator)/services/api/dashboard.ts b/servers/nextjs/app/(presentation-generator)/services/api/dashboard.ts index e4b6d34f..50826000 100644 --- a/servers/nextjs/app/(presentation-generator)/services/api/dashboard.ts +++ b/servers/nextjs/app/(presentation-generator)/services/api/dashboard.ts @@ -49,7 +49,7 @@ export class DashboardApi { static async getPresentation(id: string) { try { const response = await fetch( - `/api/v1/ppt/presentation?id=${id}`, + `/api/v1/ppt/presentation/${id}`, { method: "GET", } @@ -65,7 +65,7 @@ export class DashboardApi { static async deletePresentation(presentation_id: string) { try { const response = await fetch( - `/api/v1/ppt/presentation?id=${presentation_id}`, + `/api/v1/ppt/presentation/${presentation_id}`, { method: "DELETE", headers: getHeader(), diff --git a/servers/nextjs/app/(presentation-generator)/services/api/images.ts b/servers/nextjs/app/(presentation-generator)/services/api/images.ts index 113da7a2..5e8c15f1 100644 --- a/servers/nextjs/app/(presentation-generator)/services/api/images.ts +++ b/servers/nextjs/app/(presentation-generator)/services/api/images.ts @@ -9,7 +9,7 @@ export class ImagesApi { try { const formData = new FormData(); formData.append("file", file); - const response = await fetch(`/api/v1/ppt/images/upload-image`, { + const response = await fetch(`/api/v1/ppt/images/upload`, { method: "POST", headers: getHeaderForFormData(), body: formData, @@ -33,7 +33,7 @@ export class ImagesApi { static async deleteImage(image_id: string): Promise<{success: boolean, message?: string}> { try { - const response = await fetch(`/api/v1/ppt/images/uploaded-image/${image_id}`, { + const response = await fetch(`/api/v1/ppt/images/${image_id}`, { method: "DELETE" }); return await ApiResponseHandler.handleResponse(response, "Failed to delete image") as {success: boolean, message?: string};