diff --git a/badu.js b/badu.js deleted file mode 100644 index e69de29b..00000000 diff --git a/servers/fastapi/api/v1/ppt/endpoints/presentation.py b/servers/fastapi/api/v1/ppt/endpoints/presentation.py index 2650782d..52920367 100644 --- a/servers/fastapi/api/v1/ppt/endpoints/presentation.py +++ b/servers/fastapi/api/v1/ppt/endpoints/presentation.py @@ -312,7 +312,7 @@ async def generate_presentation_api( prompt: Annotated[str, Body()], n_slides: Annotated[int, Body()] = 8, language: Annotated[str, Body()] = "English", - layout: Annotated[str, Body()] = "general", + template: Annotated[str, Body()] = "general", files: Annotated[Optional[List[UploadFile]], File()] = None, export_as: Annotated[Literal["pptx", "pdf"], Body()] = "pptx", sql_session: AsyncSession = Depends(get_async_session), @@ -376,7 +376,7 @@ async def generate_presentation_api( print(f"Generated {total_outlines} outlines for the presentation") # 4. Parse Layouts - layout_model = await get_layout_by_name(layout) + layout_model = await get_layout_by_name(template) total_slide_layouts = len(layout_model.slides) # 5. Generate Structure diff --git a/servers/fastapi/chroma/chroma.sqlite3 b/servers/fastapi/chroma/chroma.sqlite3 deleted file mode 100644 index 60bfc98a..00000000 Binary files a/servers/fastapi/chroma/chroma.sqlite3 and /dev/null differ diff --git a/servers/fastapi/models/pptx_models.py b/servers/fastapi/models/pptx_models.py index ad596481..ee1e4cd1 100644 --- a/servers/fastapi/models/pptx_models.py +++ b/servers/fastapi/models/pptx_models.py @@ -1,5 +1,5 @@ from enum import Enum -from typing import Annotated, List, Optional +from typing import Annotated, List, Literal, Optional from annotated_types import Len from pydantic import BaseModel from pptx.util import Pt @@ -105,10 +105,11 @@ class PptxPictureModel(BaseModel): class PptxShapeModel(BaseModel): - pass + shape_type: Literal["textbox", "autoshape", "picture", "connector"] class PptxTextBoxModel(PptxShapeModel): + shape_type: Literal["textbox"] = "textbox" margin: Optional[PptxSpacingModel] = None fill: Optional[PptxFillModel] = None position: PptxPositionModel @@ -117,6 +118,7 @@ class PptxTextBoxModel(PptxShapeModel): class PptxAutoShapeBoxModel(PptxShapeModel): + shape_type: Literal["autoshape"] = "autoshape" type: MSO_AUTO_SHAPE_TYPE = MSO_AUTO_SHAPE_TYPE.RECTANGLE margin: Optional[PptxSpacingModel] = None fill: Optional[PptxFillModel] = None @@ -129,6 +131,7 @@ class PptxAutoShapeBoxModel(PptxShapeModel): class PptxPictureBoxModel(PptxShapeModel): + shape_type: Literal["picture"] = "picture" position: PptxPositionModel margin: Optional[PptxSpacingModel] = None clip: bool = True @@ -141,6 +144,7 @@ class PptxPictureBoxModel(PptxShapeModel): class PptxConnectorModel(PptxShapeModel): + shape_type: Literal["connector"] = "connector" type: MSO_CONNECTOR_TYPE = MSO_CONNECTOR_TYPE.STRAIGHT position: PptxPositionModel thickness: float = 0.5 diff --git a/servers/fastapi/utils/llm_calls/generate_presentation_outlines.py b/servers/fastapi/utils/llm_calls/generate_presentation_outlines.py index 892b9cff..8abb3c64 100644 --- a/servers/fastapi/utils/llm_calls/generate_presentation_outlines.py +++ b/servers/fastapi/utils/llm_calls/generate_presentation_outlines.py @@ -4,10 +4,7 @@ from models.llm_message import LLMSystemMessage, LLMUserMessage from models.llm_tools import GetCurrentDatetimeTool, SearchWebTool from services.llm_client import LLMClient from utils.get_dynamic_models import get_presentation_outline_model_with_n_slides -from utils.get_env import get_web_grounding_env from utils.llm_provider import get_model -from utils.parsers import parse_bool_or_none -from utils.user_config import get_user_config system_prompt = """ You are an expert presentation creator. Generate structured presentations based on user requirements and format them according to the specified JSON schema with markdown content. @@ -16,6 +13,7 @@ system_prompt = """ - Make sure that flow of the presentation is logical and consistent. - Place greater emphasis on numerical data. - If Additional Information is provided, divide it into slides. + - Make sure no images are provided in the content. - Make sure that content follows language guidelines. """ diff --git a/servers/nextjs/app/api/presentation_to_pptx_model/route.ts b/servers/nextjs/app/api/presentation_to_pptx_model/route.ts index 3c25bf42..f6dcd04d 100644 --- a/servers/nextjs/app/api/presentation_to_pptx_model/route.ts +++ b/servers/nextjs/app/api/presentation_to_pptx_model/route.ts @@ -179,7 +179,7 @@ const convertSvgToPng = async (element_attibutes: ElementAttributes) => { const svgBuffer = Buffer.from(svgHtml); const pngBuffer = await sharp(svgBuffer) - .resize(Math.round(element_attibutes.position?.width ?? 10), Math.round(element_attibutes.position?.height ?? 10)) + .resize(Math.round(element_attibutes.position!.width!), Math.round(element_attibutes.position!.height!)) .toFormat('png') .toBuffer(); return pngBuffer; @@ -261,6 +261,10 @@ async function getAllChildElementsAttributes({ element, rootRect = null, depth = }; } + if (attributes.position === undefined || attributes.position.width === undefined || attributes.position.height === undefined || attributes.position.width === 0 || attributes.position.height === 0) { + continue; + } + if (attributes.tagName === 'svg' || attributes.tagName === 'canvas' || attributes.tagName === 'table') { attributes.should_screenshot = true; attributes.element = childElementHandle; diff --git a/servers/nextjs/types/pptx_models.ts b/servers/nextjs/types/pptx_models.ts index 7ece780d..dc35cdf2 100644 --- a/servers/nextjs/types/pptx_models.ts +++ b/servers/nextjs/types/pptx_models.ts @@ -281,6 +281,7 @@ export interface PptxShapeModel { } export interface PptxTextBoxModel extends PptxShapeModel { + shape_type: string; margin?: PptxSpacingModel; fill?: PptxFillModel; position: PptxPositionModel; @@ -289,6 +290,7 @@ export interface PptxTextBoxModel extends PptxShapeModel { } export interface PptxAutoShapeBoxModel extends PptxShapeModel { + shape_type: string; type?: PptxShapeType; margin?: PptxSpacingModel; fill?: PptxFillModel; @@ -301,6 +303,7 @@ export interface PptxAutoShapeBoxModel extends PptxShapeModel { } export interface PptxPictureBoxModel extends PptxShapeModel { + shape_type: string; position: PptxPositionModel; margin?: PptxSpacingModel; clip: boolean; @@ -313,6 +316,7 @@ export interface PptxPictureBoxModel extends PptxShapeModel { } export interface PptxConnectorModel extends PptxShapeModel { + shape_type: string; type?: PptxConnectorType; position: PptxPositionModel; thickness: number; diff --git a/servers/nextjs/utils/pptx_models_utils.ts b/servers/nextjs/utils/pptx_models_utils.ts index ff72b341..e314f647 100644 --- a/servers/nextjs/utils/pptx_models_utils.ts +++ b/servers/nextjs/utils/pptx_models_utils.ts @@ -132,6 +132,7 @@ function convertToTextBox(element: ElementAttributes): PptxTextBoxModel { }; return { + shape_type: "textbox", margin: undefined, fill, position, @@ -190,6 +191,7 @@ function convertToAutoShapeBox(element: ElementAttributes): PptxAutoShapeBoxMode } return { + shape_type: "autoshape", type: shapeType, margin: undefined, fill, @@ -220,6 +222,7 @@ function convertToPictureBox(element: ElementAttributes): PptxPictureBoxModel { }; return { + shape_type: "picture", position, margin: undefined, clip: element.clip ?? true, @@ -241,6 +244,7 @@ function convertToConnector(element: ElementAttributes): PptxConnectorModel { }; return { + shape_type: "connector", type: PptxConnectorType.STRAIGHT, position, thickness: element.border?.width ?? 0.5,