diff --git a/servers/fastapi/api/main.py b/servers/fastapi/api/main.py index 93517b12..51eb2f02 100644 --- a/servers/fastapi/api/main.py +++ b/servers/fastapi/api/main.py @@ -5,6 +5,8 @@ from api.lifespan import app_lifespan from api.middlewares import UserConfigEnvUpdateMiddleware from api.v1.ppt.router import API_V1_PPT_ROUTER from utils.asset_directory_utils import get_exports_directory, get_images_directory, get_uploads_directory +# Import models to ensure they are registered with SQLModel +from models.sql.presentation_layout_code import PresentationLayoutCodeModel app = FastAPI(lifespan=app_lifespan) diff --git a/servers/fastapi/api/v1/ppt/endpoints/prompts.py b/servers/fastapi/api/v1/ppt/endpoints/prompts.py new file mode 100644 index 00000000..4ae51171 --- /dev/null +++ b/servers/fastapi/api/v1/ppt/endpoints/prompts.py @@ -0,0 +1,223 @@ + + + +GENERATE_HTML_SYSTEM_PROMPT = """ +You need to generate html and tailwind code for given presentation slide image. You need to think through each design elements and then decide where each element should go. +Follow these rules strictly: +- Make sure the design from html and tailwind is exact to the slide. +- Make sure all components are in their own place. +- Make sure size of elements are exact. +- Smallest of elements should be noted of and should be added as it is. +- Image's and icons's size and position should be added exactly as it is. +- Read through the OXML data of slide and then match exact position ans size of elements. Make sure to convert between dimension and pixels. +- Properly export shapes as exact SVG. +- Add relevant font in tailwind to all texts. +- Wrap the output code inside these classes: \"relative w-full rounded-sm max-w-[1280px] shadow-lg max-h-[720px] aspect-video bg-white relative z-20 mx-auto overflow-hidden\". For all images use this https://images.pexels.com/photos/31995895/pexels-photo-31995895/free-photo-of-turkish-coffee-with-scenic-bursa-view.jpeg url. +- Give out only HTML and Tailwind code. No other texts or explanations. + """ + +HTML_TO_REACT_SYSTEM_PROMPT = """ +Convert given static HTML and Tailwind slide to a TSX React component so that it can be dynamically populated. Follow these rules strictly while converting: + +1) Required imports, a zod schema and HTML layout has to be generated. +2) Schema will populate the layout so make sure schema has fields for all text, images and icons in the layout. +3) For similar components in the layouts (eg, team members), they should be represented by array of such components in the schema. +4) For image and icons icons should be a different schema with two dunder fields for prompt and url separately. +5) Default value for schema fields should be populated with the respective static value in HTML input. +6) In schema max and min value for characters in string and items in array should be specified as per the given image of the slide. You should accurately evaluate the maximum and minimum possible characters respective fields can handle visually through the image. +7) For image and icons schema should be compulsorily declared with two dunder fields for prompt and url separately. +8) Layout Id, layout name and layout description should be declared and should describe the structure of the layout not its purpose. Do not describe numbers of any items in the layout. + -Description should not have any purpose for elements in it, so use 'cards' instead of 'goal cards' and 'bullet points' instead of 'solution bullet points'. + -layoutName constant should be same as the component name in the layout. + -Layout Id examples: header-description-bullet-points-slide, header-description-image-slide + -Layout Name examples: HeaderDescriptionBulletPointsLayout, HeaderDescriptionImageLayout + -Layout Description examples: A slide with a header, description, and bullet points and A slide with a header, description, and image + +For example: +Input:
Effects of Global Warming

Global warming triggers a cascade of effects on our planet. These changes impact everything from our oceans to our ecosystems.
Rising Sea Levels
Rising sea levels threaten coastal communities and ecosystems due to melting glaciers and thermal expansion.
Intense Heatwaves
Heatwaves are becoming more frequent and intense, posing significant risks to human health and agriculture.
Changes in Precipitation
Altered precipitation patterns lead to increased droughts in some regions and severe flooding in others, affecting water resources.
+ {slideData?.description || 'Businesses face challenges with outdated technology and rising costs, limiting efficiency and growth in competitive markets.'} +
+ + {/* Bullet Points */} ++ {bullet.description} +
+