merge
This commit is contained in:
Suraj Jha 2025-08-10 18:18:40 +05:45
commit 9d546eaab0
No known key found for this signature in database
GPG key ID: 5AC6C16355CE2C14
8 changed files with 22 additions and 8 deletions

View file

View file

@ -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

View file

@ -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

View file

@ -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.
"""

View file

@ -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;

View file

@ -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;

View file

@ -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,