Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,7 +41,7 @@ The output MUST include only:
|
|
| 41 |
• The graph code (using D3.js) that uses data relevant to:
|
| 42 |
{placeholder_text}
|
| 43 |
Ensure that no extraneous content (such as discussion, concluding remarks, or additional text) is included.
|
| 44 |
-
|
| 45 |
Output the result starting with <html> and ending with </html> with no additional comments.
|
| 46 |
|
| 47 |
// Sources:
|
|
@@ -87,7 +87,7 @@ Keep in mind the:
|
|
| 87 |
}
|
| 88 |
#chart {
|
| 89 |
width: 100%;
|
| 90 |
-
max-height:
|
| 91 |
}
|
| 92 |
.axis-label {
|
| 93 |
font-size: 14px;
|
|
@@ -216,8 +216,8 @@ Keep in mind the:
|
|
| 216 |
margin: 20px 0;
|
| 217 |
}
|
| 218 |
#chart {
|
| 219 |
-
width:
|
| 220 |
-
max-height:
|
| 221 |
}
|
| 222 |
.axis path,
|
| 223 |
.axis line {
|
|
@@ -379,8 +379,8 @@ Keep in mind the:
|
|
| 379 |
color: #333;
|
| 380 |
}
|
| 381 |
#chart {
|
| 382 |
-
width:
|
| 383 |
-
max-height:
|
| 384 |
background-color: #fff;
|
| 385 |
border: 1px solid #ddd;
|
| 386 |
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
|
|
@@ -525,7 +525,7 @@ Keep in mind the:
|
|
| 525 |
result = result.strip().strip("```").strip()
|
| 526 |
htmloutput = f"""<iframe class="visual-frame" srcdoc='
|
| 527 |
<!DOCTYPE html>
|
| 528 |
-
{result}' width="
|
| 529 |
"""
|
| 530 |
|
| 531 |
logging.info(f"The code produced for this graph placeholder:\n{placeholder_text}\n\n {htmloutput}\n\n")
|
|
@@ -576,7 +576,7 @@ def generate_visual_snippet(placeholder_text: str, context: str, initial_query:
|
|
| 576 |
Generate a mermaid code displaying a simple but effective and elegant visualization based on the following requirements:
|
| 577 |
{placeholder_text}
|
| 578 |
|
| 579 |
-
It will be integrated in a broader report
|
| 580 |
{initial_query}
|
| 581 |
|
| 582 |
// Sources:
|
|
@@ -607,7 +607,8 @@ G --> H[Performance Evaluation - 45% Speed Improvement, 35% Risk Profiling, 50%
|
|
| 607 |
Note: Visual placeholders are solely supposed to generate diagrams not for graphs.
|
| 608 |
- use only this type of quotation marks: ", others would lead to failure to render
|
| 609 |
- if you need to render a quotation mark inside the text of the diagram make sure to add escapechar so that mermaid interprets it correctly
|
| 610 |
-
- do not use commas in the content of each object / nodes, they will create rendering issues
|
|
|
|
| 611 |
- Take a deep breath, think step by step and think it well.
|
| 612 |
|
| 613 |
// Examples
|
|
@@ -615,9 +616,10 @@ Note: Pay attention for each example to what type of parenthesis / bracket is us
|
|
| 615 |
|
| 616 |
-- flowchart --
|
| 617 |
Important:
|
|
|
|
| 618 |
- If the flow is "broader" than deep (>3 branches at the same level), choose LR (Left Right)
|
| 619 |
-
- If the flow is "deeper" than broad (>3 levels), choose TD (Top Down)
|
| 620 |
- There can be mix of flows that can be elaborate
|
|
|
|
| 621 |
|
| 622 |
Top Down:
|
| 623 |
|
|
@@ -770,7 +772,7 @@ mindmap
|
|
| 770 |
{result}
|
| 771 |
</div>
|
| 772 |
</body>
|
| 773 |
-
</html>' width="
|
| 774 |
"""
|
| 775 |
|
| 776 |
logging.info(f"The code produced for this visual placeholder:\n{placeholder_text}\n\n {htmloutput}\n\n")
|
|
@@ -823,6 +825,7 @@ def generate_focus_snippet(placeholder_text: str, context: str, initial_query: s
|
|
| 823 |
Generate a complete, self-contained inner-HTML code (only the content inside <div> tags, no outer <html> tags) with inline CSS.
|
| 824 |
The code should provide an elaborate technical drill‐down on the topic:
|
| 825 |
{placeholder_text}
|
|
|
|
| 826 |
The output must be between 1000 and 2000 words.
|
| 827 |
- Use clear sub‑titles (bold them or use <h3> tags) and paragraphs to break the content.
|
| 828 |
|
|
@@ -837,7 +840,8 @@ Keep in mind the:
|
|
| 837 |
{crumbs}
|
| 838 |
|
| 839 |
// Critical Requirements
|
| 840 |
-
It MUST include inline citations using the format [1], [2], etc., that exactly match the reference numbering used in the overall report.
|
|
|
|
| 841 |
- Use html with css to render it, keep it sober and focused on the content
|
| 842 |
- The output has to be boxed in a border of 1px Black
|
| 843 |
- Font size minimum 12px for readability in PDF
|
|
@@ -849,7 +853,7 @@ It MUST include inline citations using the format [1], [2], etc., that exactly m
|
|
| 849 |
- Ground the content on the inputs shared above (context and knowledge inputs) with facts and numbers
|
| 850 |
- Take a deep breath, think step by step and think it well.
|
| 851 |
- no introduction, conclusions, code fences -> Output the result directly
|
| 852 |
-
- title should be h2 level then the content
|
| 853 |
""")
|
| 854 |
|
| 855 |
result = openai_call(prompt, model="o3-mini", max_tokens_param=10000)
|
|
@@ -1190,7 +1194,7 @@ The report should be very detailed and lengthy — approximately the equivalent
|
|
| 1190 |
- Do not add any inline citations reference in the placeholders descriptions below (visual, graph or focus)
|
| 1191 |
- Don't make too large blocks, skip lines and add line breaks when changing topic.
|
| 1192 |
- The report must include between {round(pages/3.3,0)} and {round(pages/2,0)} tables from the sources used (add citations if necessary) and use facts and figures extensively to ground the analysis.
|
| 1193 |
-
- The report MUST include a reference summary table with
|
| 1194 |
- For the numbering of titles or numbered lists, use numbers (ex: 1.) and sub-units (1.1, 1.2... 1.1.1...,1.1.2...).
|
| 1195 |
Note: Exclude the use of html numbered lists format, they don't get correctly implemented. Use plain text format for numbering of sections and sub-sections
|
| 1196 |
- For the reference citations, add systematically the urls from the Learnings (no need to put them in numbered list format since we alredy have the [x] that serves as number list)
|
|
@@ -1225,17 +1229,17 @@ with:
|
|
| 1225 |
- source_name as the main source used and
|
| 1226 |
- y as the source reference in the reference table.
|
| 1227 |
Important:
|
|
|
|
|
|
|
| 1228 |
- after [[ put "Visual Placeholder n:" explicitly (with n as the ref number of the visual box created). This will be used in a regex
|
| 1229 |
-
- before [[...]] do not put any title for the placeholder, just mention the source
|
| 1230 |
-
- use h4 tag for the source and source reference number
|
| 1231 |
- the only types of mermaid diagram that can be generated are: flowchart, sequence, gantt, pie, mindmap (no charts) // Take this into consideration when providing the instructions for the diagram
|
| 1232 |
-
- do not make reference in the report to "visual placeholders" just mention
|
| 1233 |
- in the placeholder, no need to add the references to the source or its ref number, but make sure ALL of the data points required has a source from the learning and reference material hereafter
|
| 1234 |
- these placeholders text should contain:
|
| 1235 |
o the purpose of the future visual
|
| 1236 |
o the relevant data to generate it
|
| 1237 |
- there should be between {round(pages/3.3,0)} and {round(pages/2.5,0)} of these visuals placeholders within the report (all between introduction and conclusion)
|
| 1238 |
-
- 2 visual placeholders cannot be in the same section
|
| 1239 |
Note: the placeholders will then be processed separately by a llm to generate the specific code to display each of them so the instruction need to be clear enough.
|
| 1240 |
|
| 1241 |
// Graph placeholders
|
|
@@ -1252,9 +1256,9 @@ with:
|
|
| 1252 |
- source_name as the main source used and
|
| 1253 |
- y as the source reference in the reference table.
|
| 1254 |
Important:
|
|
|
|
|
|
|
| 1255 |
- after [[ put "Graph Placeholder n:" explicitly (with n as the ref number of the graph created). This will be used in a regex
|
| 1256 |
-
- use h4 tag for the source and source reference number
|
| 1257 |
-
- before [[...]] do not put any title for the placeholder, just mention the source
|
| 1258 |
|
| 1259 |
- All types of graphs (using d3.js library) can be generated // Take this into consideration when providing the instructions for the graph data
|
| 1260 |
- do not make mention in the report to "graph placeholders" just mention graph.
|
|
@@ -1269,8 +1273,8 @@ Note: the placeholders will then be processed separately by a llm to generate th
|
|
| 1269 |
// Focus placeholders
|
| 1270 |
- To drill down on specific topic that would be deserve to be developped extensively separately, create special focus placeholders in [[...]] double backets
|
| 1271 |
Note: outside of the placeholder, do not make reference in the report to "focus placeholders" just mention the "Focus box n".
|
| 1272 |
-
- in the placeholder, make a mention to the prescribed sources used
|
| 1273 |
-
- do not make the placeholder
|
| 1274 |
o a special case that deserves attention
|
| 1275 |
o a recent development / innovation
|
| 1276 |
o a theoretical drill-down
|
|
@@ -1281,10 +1285,9 @@ Note: outside of the placeholder, do not make reference in the report to "focus
|
|
| 1281 |
o the guidance in terms of style and message to convey
|
| 1282 |
Note: Be specific if you want some particular point developped, keep it consistent across the report.
|
| 1283 |
- there should be between {round(pages/5,0)} and {round(pages/3.3,0)} of these focus placeholders within the report (all between introduction and conclusion)
|
| 1284 |
-
- 2 focus placeholders cannot be in the same section
|
| 1285 |
- Mention all the sources that should be used to generate this focus placeholder and list also the references that will be mentioned in the References section later (ex: [1], [2])
|
| 1286 |
-
|
| 1287 |
-
Note: the placeholders will then be processed separately by a llm to generate the specific code to display each of them so the instruction need to be clear enough.
|
| 1288 |
|
| 1289 |
// Format:
|
| 1290 |
[[Focus Placeholder n:
|
|
|
|
| 41 |
• The graph code (using D3.js) that uses data relevant to:
|
| 42 |
{placeholder_text}
|
| 43 |
Ensure that no extraneous content (such as discussion, concluding remarks, or additional text) is included.
|
| 44 |
+
Take in consideration that the resulting iframe content will render 1400px width and and 800px high.
|
| 45 |
Output the result starting with <html> and ending with </html> with no additional comments.
|
| 46 |
|
| 47 |
// Sources:
|
|
|
|
| 87 |
}
|
| 88 |
#chart {
|
| 89 |
width: 100%;
|
| 90 |
+
max-height: 800px;
|
| 91 |
}
|
| 92 |
.axis-label {
|
| 93 |
font-size: 14px;
|
|
|
|
| 216 |
margin: 20px 0;
|
| 217 |
}
|
| 218 |
#chart {
|
| 219 |
+
width: 1400px;
|
| 220 |
+
max-height: 800px;
|
| 221 |
}
|
| 222 |
.axis path,
|
| 223 |
.axis line {
|
|
|
|
| 379 |
color: #333;
|
| 380 |
}
|
| 381 |
#chart {
|
| 382 |
+
width: 1400;
|
| 383 |
+
max-height: 800px;
|
| 384 |
background-color: #fff;
|
| 385 |
border: 1px solid #ddd;
|
| 386 |
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
|
|
|
|
| 525 |
result = result.strip().strip("```").strip()
|
| 526 |
htmloutput = f"""<iframe class="visual-frame" srcdoc='
|
| 527 |
<!DOCTYPE html>
|
| 528 |
+
{result}' width="1400px" height="800px" style="border:none;"></iframe>
|
| 529 |
"""
|
| 530 |
|
| 531 |
logging.info(f"The code produced for this graph placeholder:\n{placeholder_text}\n\n {htmloutput}\n\n")
|
|
|
|
| 576 |
Generate a mermaid code displaying a simple but effective and elegant visualization based on the following requirements:
|
| 577 |
{placeholder_text}
|
| 578 |
|
| 579 |
+
It will be integrated in a broader report about:
|
| 580 |
{initial_query}
|
| 581 |
|
| 582 |
// Sources:
|
|
|
|
| 607 |
Note: Visual placeholders are solely supposed to generate diagrams not for graphs.
|
| 608 |
- use only this type of quotation marks: ", others would lead to failure to render
|
| 609 |
- if you need to render a quotation mark inside the text of the diagram make sure to add escapechar so that mermaid interprets it correctly
|
| 610 |
+
- do not use commas in the content of each object / nodes, they will create rendering issues
|
| 611 |
+
- Take in consideration that the resulting iframe content will render 1400px width and and 800px high.
|
| 612 |
- Take a deep breath, think step by step and think it well.
|
| 613 |
|
| 614 |
// Examples
|
|
|
|
| 616 |
|
| 617 |
-- flowchart --
|
| 618 |
Important:
|
| 619 |
+
- If the flow is "deeper" than broad (>3 levels), choose TD (Top Down) ==> TD is the default one if you have a doubt
|
| 620 |
- If the flow is "broader" than deep (>3 branches at the same level), choose LR (Left Right)
|
|
|
|
| 621 |
- There can be mix of flows that can be elaborate
|
| 622 |
+
- Take in consideration that the resulting iframe content will render 1400px width and and 800px high. Make the best of the areas real-estate.
|
| 623 |
|
| 624 |
Top Down:
|
| 625 |
|
|
|
|
| 772 |
{result}
|
| 773 |
</div>
|
| 774 |
</body>
|
| 775 |
+
</html>' width="1400px" height="800px" style="border:none;"></iframe>
|
| 776 |
"""
|
| 777 |
|
| 778 |
logging.info(f"The code produced for this visual placeholder:\n{placeholder_text}\n\n {htmloutput}\n\n")
|
|
|
|
| 825 |
Generate a complete, self-contained inner-HTML code (only the content inside <div> tags, no outer <html> tags) with inline CSS.
|
| 826 |
The code should provide an elaborate technical drill‐down on the topic:
|
| 827 |
{placeholder_text}
|
| 828 |
+
|
| 829 |
The output must be between 1000 and 2000 words.
|
| 830 |
- Use clear sub‑titles (bold them or use <h3> tags) and paragraphs to break the content.
|
| 831 |
|
|
|
|
| 840 |
{crumbs}
|
| 841 |
|
| 842 |
// Critical Requirements
|
| 843 |
+
- It MUST include inline citations using the format [1], [2], etc., that exactly match the reference numbering used in the overall report.
|
| 844 |
+
Note: no need to add a reference table at the end of the focus box, all the references / citations have already been listed at the end of the report (just refer to the [x] provided in the placeholder instructions)
|
| 845 |
- Use html with css to render it, keep it sober and focused on the content
|
| 846 |
- The output has to be boxed in a border of 1px Black
|
| 847 |
- Font size minimum 12px for readability in PDF
|
|
|
|
| 853 |
- Ground the content on the inputs shared above (context and knowledge inputs) with facts and numbers
|
| 854 |
- Take a deep breath, think step by step and think it well.
|
| 855 |
- no introduction, conclusions, code fences -> Output the result directly
|
| 856 |
+
- title should be h2 level (inside the focus box) then the content
|
| 857 |
""")
|
| 858 |
|
| 859 |
result = openai_call(prompt, model="o3-mini", max_tokens_param=10000)
|
|
|
|
| 1194 |
- Do not add any inline citations reference in the placeholders descriptions below (visual, graph or focus)
|
| 1195 |
- Don't make too large blocks, skip lines and add line breaks when changing topic.
|
| 1196 |
- The report must include between {round(pages/3.3,0)} and {round(pages/2,0)} tables from the sources used (add citations if necessary) and use facts and figures extensively to ground the analysis.
|
| 1197 |
+
- The report MUST include a reference summary table with between 10 (for a 8 page report) and 30 references (for a 40 pages report). All inline citations (e.g., [1], [2], …) present in the report and in any focus placeholders MUST have a corresponding entry in this table with its full URL.
|
| 1198 |
- For the numbering of titles or numbered lists, use numbers (ex: 1.) and sub-units (1.1, 1.2... 1.1.1...,1.1.2...).
|
| 1199 |
Note: Exclude the use of html numbered lists format, they don't get correctly implemented. Use plain text format for numbering of sections and sub-sections
|
| 1200 |
- For the reference citations, add systematically the urls from the Learnings (no need to put them in numbered list format since we alredy have the [x] that serves as number list)
|
|
|
|
| 1229 |
- source_name as the main source used and
|
| 1230 |
- y as the source reference in the reference table.
|
| 1231 |
Important:
|
| 1232 |
+
- before [[...]] do not put any title for the placeholder, just mention the source with the reference number
|
| 1233 |
+
- use p tag for the source and source reference number
|
| 1234 |
- after [[ put "Visual Placeholder n:" explicitly (with n as the ref number of the visual box created). This will be used in a regex
|
|
|
|
|
|
|
| 1235 |
- the only types of mermaid diagram that can be generated are: flowchart, sequence, gantt, pie, mindmap (no charts) // Take this into consideration when providing the instructions for the diagram
|
| 1236 |
+
- do not make reference in the report to "visual placeholders" just mention the visual and the number..
|
| 1237 |
- in the placeholder, no need to add the references to the source or its ref number, but make sure ALL of the data points required has a source from the learning and reference material hereafter
|
| 1238 |
- these placeholders text should contain:
|
| 1239 |
o the purpose of the future visual
|
| 1240 |
o the relevant data to generate it
|
| 1241 |
- there should be between {round(pages/3.3,0)} and {round(pages/2.5,0)} of these visuals placeholders within the report (all between introduction and conclusion)
|
| 1242 |
+
- 2 visual placeholders cannot be in the same section
|
| 1243 |
Note: the placeholders will then be processed separately by a llm to generate the specific code to display each of them so the instruction need to be clear enough.
|
| 1244 |
|
| 1245 |
// Graph placeholders
|
|
|
|
| 1256 |
- source_name as the main source used and
|
| 1257 |
- y as the source reference in the reference table.
|
| 1258 |
Important:
|
| 1259 |
+
- before [[...]] do not put any title for the placeholder, just mention the source with the reference number
|
| 1260 |
+
- use p tag for the source and source reference number
|
| 1261 |
- after [[ put "Graph Placeholder n:" explicitly (with n as the ref number of the graph created). This will be used in a regex
|
|
|
|
|
|
|
| 1262 |
|
| 1263 |
- All types of graphs (using d3.js library) can be generated // Take this into consideration when providing the instructions for the graph data
|
| 1264 |
- do not make mention in the report to "graph placeholders" just mention graph.
|
|
|
|
| 1273 |
// Focus placeholders
|
| 1274 |
- To drill down on specific topic that would be deserve to be developped extensively separately, create special focus placeholders in [[...]] double backets
|
| 1275 |
Note: outside of the placeholder, do not make reference in the report to "focus placeholders" just mention the "Focus box n".
|
| 1276 |
+
- in the Focus placeholder, make a mention to the prescribed sources used (no need to add the source before or after the placeholder)
|
| 1277 |
+
- do not make the placeholder on the exact same topic as the section or the sub-section where it is positioned, it has to be either:
|
| 1278 |
o a special case that deserves attention
|
| 1279 |
o a recent development / innovation
|
| 1280 |
o a theoretical drill-down
|
|
|
|
| 1285 |
o the guidance in terms of style and message to convey
|
| 1286 |
Note: Be specific if you want some particular point developped, keep it consistent across the report.
|
| 1287 |
- there should be between {round(pages/5,0)} and {round(pages/3.3,0)} of these focus placeholders within the report (all between introduction and conclusion)
|
| 1288 |
+
- 2 focus placeholders cannot be in the same section and should be a few pages apart in the report
|
| 1289 |
- Mention all the sources that should be used to generate this focus placeholder and list also the references that will be mentioned in the References section later (ex: [1], [2])
|
| 1290 |
+
Note: the Focus placeholders will then be processed separately by a llm to generate the specific code to display each of them so the instruction need to be clear enough.
|
|
|
|
| 1291 |
|
| 1292 |
// Format:
|
| 1293 |
[[Focus Placeholder n:
|