Spaces:
Running
Running
Merge pull request #102 from barun-saha/visual
Browse filesUpdate code and prompts to enable slides with tables (only)
helpers/pptx_helper.py
CHANGED
@@ -179,6 +179,14 @@ def generate_powerpoint_presentation(
|
|
179 |
slide_height_inch=slide_height_inch
|
180 |
)
|
181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
if not is_processing_done:
|
183 |
is_processing_done = _handle_double_col_layout(
|
184 |
presentation=presentation,
|
@@ -853,6 +861,51 @@ def _handle_step_by_step_process(
|
|
853 |
return True
|
854 |
|
855 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
856 |
def _handle_key_message(
|
857 |
the_slide: pptx.slide.Slide,
|
858 |
slide_json: dict,
|
@@ -988,6 +1041,22 @@ if __name__ == '__main__':
|
|
988 |
"key_message": "AI encompasses various aspects, from human-like intelligence to global impact",
|
989 |
"img_keywords": "AI aspects, intelligence, automation, data processing, global impact"
|
990 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
991 |
{
|
992 |
"heading": "Conclusion: Embracing AI's Potential",
|
993 |
"bullet_points": [
|
|
|
179 |
slide_height_inch=slide_height_inch
|
180 |
)
|
181 |
|
182 |
+
if not is_processing_done:
|
183 |
+
is_processing_done = _handle_table(
|
184 |
+
presentation=presentation,
|
185 |
+
slide_json=a_slide,
|
186 |
+
slide_width_inch=slide_width_inch,
|
187 |
+
slide_height_inch=slide_height_inch
|
188 |
+
)
|
189 |
+
|
190 |
if not is_processing_done:
|
191 |
is_processing_done = _handle_double_col_layout(
|
192 |
presentation=presentation,
|
|
|
861 |
return True
|
862 |
|
863 |
|
864 |
+
def _handle_table(
|
865 |
+
presentation: pptx.Presentation,
|
866 |
+
slide_json: dict,
|
867 |
+
slide_width_inch: float,
|
868 |
+
slide_height_inch: float
|
869 |
+
) -> bool:
|
870 |
+
"""
|
871 |
+
Add a table to a slide, if available.
|
872 |
+
|
873 |
+
:param presentation: The presentation object.
|
874 |
+
:param slide_json: The content of the slide as JSON data.
|
875 |
+
:param slide_width_inch: The width of the slide in inches.
|
876 |
+
:param slide_height_inch: The height of the slide in inches.
|
877 |
+
:return True if this slide has a step-by-step process depiction added; False otherwise.
|
878 |
+
"""
|
879 |
+
|
880 |
+
if 'table' not in slide_json or not slide_json['table']:
|
881 |
+
return False
|
882 |
+
|
883 |
+
headers = slide_json['table'].get('headers', [])
|
884 |
+
rows = slide_json['table'].get('rows', [])
|
885 |
+
bullet_slide_layout = presentation.slide_layouts[1]
|
886 |
+
slide = presentation.slides.add_slide(bullet_slide_layout)
|
887 |
+
shapes = slide.shapes
|
888 |
+
shapes.title.text = remove_slide_number_from_heading(slide_json['heading'])
|
889 |
+
left = slide.placeholders[1].left
|
890 |
+
top = slide.placeholders[1].top
|
891 |
+
width = slide.placeholders[1].width
|
892 |
+
height = slide.placeholders[1].height
|
893 |
+
table = slide.shapes.add_table(len(rows) + 1, len(headers), left, top, width, height).table
|
894 |
+
|
895 |
+
# Set headers
|
896 |
+
for col_idx, header_text in enumerate(headers):
|
897 |
+
table.cell(0, col_idx).text = header_text
|
898 |
+
table.cell(0, col_idx).text_frame.paragraphs[
|
899 |
+
0].font.bold = True # Make header bold
|
900 |
+
|
901 |
+
# Fill in rows
|
902 |
+
for row_idx, row_data in enumerate(rows, start=1):
|
903 |
+
for col_idx, cell_text in enumerate(row_data):
|
904 |
+
table.cell(row_idx, col_idx).text = cell_text
|
905 |
+
|
906 |
+
return True
|
907 |
+
|
908 |
+
|
909 |
def _handle_key_message(
|
910 |
the_slide: pptx.slide.Slide,
|
911 |
slide_json: dict,
|
|
|
1041 |
"key_message": "AI encompasses various aspects, from human-like intelligence to global impact",
|
1042 |
"img_keywords": "AI aspects, intelligence, automation, data processing, global impact"
|
1043 |
},
|
1044 |
+
{
|
1045 |
+
"heading": "AI vs. ML vs. DL: A Tabular Comparison",
|
1046 |
+
"table": {
|
1047 |
+
"headers": ["Feature", "AI", "ML", "DL"],
|
1048 |
+
"rows": [
|
1049 |
+
["Definition", "Creating intelligent agents", "Learning from data", "Deep neural networks"],
|
1050 |
+
["Approach", "Rule-based, expert systems", "Algorithms, statistical models", "Deep neural networks"],
|
1051 |
+
["Data Requirements", "Varies", "Large datasets", "Massive datasets"],
|
1052 |
+
["Complexity", "Varies", "Moderate", "High"],
|
1053 |
+
["Computational Cost", "Low to Moderate", "Moderate", "High"],
|
1054 |
+
["Examples", "Chess, recommendation systems", "Spam filters, image recognition", "Image recognition, NLP"]
|
1055 |
+
]
|
1056 |
+
},
|
1057 |
+
"key_message": "This table provides a concise comparison of the key features of AI, ML, and DL.",
|
1058 |
+
"img_keywords": "AI, ML, DL, comparison, table, features"
|
1059 |
+
},
|
1060 |
{
|
1061 |
"heading": "Conclusion: Embracing AI's Potential",
|
1062 |
"bullet_points": [
|
prompts/initial_template_v4_two_cols_img.txt
CHANGED
@@ -4,6 +4,9 @@ Create the slides for a presentation on the given topic.
|
|
4 |
Include main headings for each slide, detailed bullet points for each slide.
|
5 |
Add relevant, detailed content to each slide. When relevant, add one or two EXAMPLES to illustrate the concept.
|
6 |
For two or three important slides, generate the key message that those slides convey.
|
|
|
|
|
|
|
7 |
|
8 |
The <ADDITIONAL_INFO> may provide additional information. If available, you should incorporate them while making the slides.
|
9 |
Read this information carefully. Based on the contents provided, organize the presentation.
|
@@ -12,6 +15,7 @@ If it's a product brochure, you can have Features, Changes, Operating Conditions
|
|
12 |
Similarly, decide for other content types. Then appropriately incorporate the contents into the relevant slides, presenting in a useful way.
|
13 |
If you find that <ADDITIONAL_INFO> contains text from a document and said document has a title, use the same title for the slide deck.
|
14 |
If there are important content, e.g., equations and theorems, try to capture a few of them.
|
|
|
15 |
If <ADDITIONAL_INFO> is empty, ignore the section and the related instructions.
|
16 |
|
17 |
Identify if a slide describes a step-by-step/sequential process, then begin the bullet points with a special marker >>.
|
@@ -108,6 +112,19 @@ The output must be only a valid and syntactically correct JSON adhering to the f
|
|
108 |
],
|
109 |
"key_message": "",
|
110 |
"img_keywords": ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
}}
|
112 |
]
|
113 |
}}
|
|
|
4 |
Include main headings for each slide, detailed bullet points for each slide.
|
5 |
Add relevant, detailed content to each slide. When relevant, add one or two EXAMPLES to illustrate the concept.
|
6 |
For two or three important slides, generate the key message that those slides convey.
|
7 |
+
Present numbers/facts in slides with tables whenever applicable.
|
8 |
+
Any slide with a table must not have any other content such as bullet points.
|
9 |
+
E.g., you can tabulate data to summarize some facts on the topic, metrics, experimental settings/results, compare features, and so on.
|
10 |
|
11 |
The <ADDITIONAL_INFO> may provide additional information. If available, you should incorporate them while making the slides.
|
12 |
Read this information carefully. Based on the contents provided, organize the presentation.
|
|
|
15 |
Similarly, decide for other content types. Then appropriately incorporate the contents into the relevant slides, presenting in a useful way.
|
16 |
If you find that <ADDITIONAL_INFO> contains text from a document and said document has a title, use the same title for the slide deck.
|
17 |
If there are important content, e.g., equations and theorems, try to capture a few of them.
|
18 |
+
Overall, rather than creating a bulleted list of all information, present them in a meaningful way.
|
19 |
If <ADDITIONAL_INFO> is empty, ignore the section and the related instructions.
|
20 |
|
21 |
Identify if a slide describes a step-by-step/sequential process, then begin the bullet points with a special marker >>.
|
|
|
112 |
],
|
113 |
"key_message": "",
|
114 |
"img_keywords": ""
|
115 |
+
}},
|
116 |
+
{{
|
117 |
+
"heading": "Slide with a table",
|
118 |
+
"table": {{
|
119 |
+
"headers": ["Column 1", "Column 2", "Column 3"],
|
120 |
+
"rows": [
|
121 |
+
["Row 1, Col 1", "Row 1, Col 2", "Row 1, Col 3"],
|
122 |
+
["Row 2, Col 1", "Row 2, Col 2", "Row 2, Col 3"],
|
123 |
+
["Row 3, Col 1", "Row 3, Col 2", "Row 3, Col 3"]
|
124 |
+
]
|
125 |
+
}},
|
126 |
+
"key_message": "",
|
127 |
+
"img_keywords": "leave empty"
|
128 |
}}
|
129 |
]
|
130 |
}}
|
prompts/refinement_template_v4_two_cols_img.txt
CHANGED
@@ -7,6 +7,9 @@ You will not repeat any slide.
|
|
7 |
Include main headings for each slide, detailed bullet points for each slide.
|
8 |
Add relevant, detailed content to each slide. When relevant, add one or two EXAMPLES to illustrate the concept.
|
9 |
For two or three important slides, generate the key message that those slides convey.
|
|
|
|
|
|
|
10 |
|
11 |
The <ADDITIONAL_INFO> may provide additional information. If available, you should incorporate them while making the slides.
|
12 |
Read this information carefully. Based on the contents provided, organize the presentation.
|
@@ -15,6 +18,7 @@ If it's a product brochure, you can have Features, Changes, Operating Conditions
|
|
15 |
Similarly, decide for other content types. Then appropriately incorporate the contents into the relevant slides, presenting in a useful way.
|
16 |
If you find that <ADDITIONAL_INFO> contains text from a document and said document has a title, use the same title for the slide deck.
|
17 |
If there are important content, e.g., equations and theorems, try to capture a few of them.
|
|
|
18 |
If <ADDITIONAL_INFO> is empty, ignore the section and the related instructions.
|
19 |
|
20 |
Identify if a slide describes a step-by-step/sequential process, then begin the bullet points with a special marker >>. Limit this to max two or three slides.
|
@@ -27,6 +31,7 @@ If there is no slide with icons, create one slide containing 4 TO 6 icons (picto
|
|
27 |
In this slide, each line of text will begin with the name of a relevant icon enclosed between [[ and ]], e.g., [[machine-learning]] and [[fairness]].
|
28 |
Insert icons only in this slide. Do not repeat any icons or the icons slide.
|
29 |
Do not add another slide with icons if it already exists. However, you can update the existing slide if required.
|
|
|
30 |
|
31 |
The content of each slide should be detailed and descriptive but not way too verbose.
|
32 |
Avoid writing like a report, but also avoid very short bullet points with just 3-4 words.
|
@@ -115,6 +120,19 @@ The output must be only a valid and syntactically correct JSON adhering to the f
|
|
115 |
],
|
116 |
"key_message": "",
|
117 |
"img_keywords": ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}}
|
119 |
]
|
120 |
}}
|
|
|
7 |
Include main headings for each slide, detailed bullet points for each slide.
|
8 |
Add relevant, detailed content to each slide. When relevant, add one or two EXAMPLES to illustrate the concept.
|
9 |
For two or three important slides, generate the key message that those slides convey.
|
10 |
+
Present numbers/facts in slides with tables whenever applicable.
|
11 |
+
Any slide with a table must not have any other content such as bullet points.
|
12 |
+
E.g., you can tabulate data to summarize some facts on the topic, metrics, experimental settings/results, compare features, and so on.
|
13 |
|
14 |
The <ADDITIONAL_INFO> may provide additional information. If available, you should incorporate them while making the slides.
|
15 |
Read this information carefully. Based on the contents provided, organize the presentation.
|
|
|
18 |
Similarly, decide for other content types. Then appropriately incorporate the contents into the relevant slides, presenting in a useful way.
|
19 |
If you find that <ADDITIONAL_INFO> contains text from a document and said document has a title, use the same title for the slide deck.
|
20 |
If there are important content, e.g., equations and theorems, try to capture a few of them.
|
21 |
+
Overall, rather than creating a bulleted list of all information, present them in a meaningful way.
|
22 |
If <ADDITIONAL_INFO> is empty, ignore the section and the related instructions.
|
23 |
|
24 |
Identify if a slide describes a step-by-step/sequential process, then begin the bullet points with a special marker >>. Limit this to max two or three slides.
|
|
|
31 |
In this slide, each line of text will begin with the name of a relevant icon enclosed between [[ and ]], e.g., [[machine-learning]] and [[fairness]].
|
32 |
Insert icons only in this slide. Do not repeat any icons or the icons slide.
|
33 |
Do not add another slide with icons if it already exists. However, you can update the existing slide if required.
|
34 |
+
Similarly, do not add the same table (if any) again.
|
35 |
|
36 |
The content of each slide should be detailed and descriptive but not way too verbose.
|
37 |
Avoid writing like a report, but also avoid very short bullet points with just 3-4 words.
|
|
|
120 |
],
|
121 |
"key_message": "",
|
122 |
"img_keywords": ""
|
123 |
+
}},
|
124 |
+
{{
|
125 |
+
"heading": "Slide with a Table (add only when useful based on the context)",
|
126 |
+
"table": {{
|
127 |
+
"headers": ["Column 1", "Column 2", "Column 3"],
|
128 |
+
"rows": [
|
129 |
+
["Row 1, Col 1", "Row 1, Col 2", "Row 1, Col 3"],
|
130 |
+
["Row 2, Col 1", "Row 2, Col 2", "Row 2, Col 3"],
|
131 |
+
["Row 3, Col 1", "Row 3, Col 2", "Row 3, Col 3"]
|
132 |
+
]
|
133 |
+
}},
|
134 |
+
"key_message": "",
|
135 |
+
"img_keywords": "leave empty"
|
136 |
}}
|
137 |
]
|
138 |
}}
|