feat: use new endpoints in UI
This commit is contained in:
parent
a992f40077
commit
f80a278c34
7 changed files with 23 additions and 28 deletions
|
|
@ -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)
|
||||
):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue