Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
# =============================================================================
|
| 2 |
# By T.Sakai / G.Huet
|
| 3 |
# =============================================================================
|
| 4 |
-
|
| 5 |
import os
|
| 6 |
import time
|
| 7 |
import io
|
|
@@ -930,6 +929,10 @@ def replace_graph_placeholders(report_html: str, context: str, initial_query: st
|
|
| 930 |
|
| 931 |
try:
|
| 932 |
visual_html = generate_graph_snippet(instructions, context, initial_query, crumbs)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 933 |
return f'<!-- Graph {placeholder_num} Start -->\n<div class="graph-container" style="margin:20px 0;">\n{visual_html}\n</div>\n<!-- Graph {placeholder_num} End -->'
|
| 934 |
except Exception as e:
|
| 935 |
logging.error(f"Graph {placeholder_num} failed: {str(e)}")
|
|
@@ -1184,6 +1187,9 @@ def replace_visual_placeholders(report_html: str, context: str, initial_query: s
|
|
| 1184 |
|
| 1185 |
try:
|
| 1186 |
visual_html = generate_visual_snippet(instructions, context, initial_query, crumbs)
|
|
|
|
|
|
|
|
|
|
| 1187 |
# Add error boundary and logging
|
| 1188 |
return f'<!-- Visual {placeholder_num} Start -->\n{visual_html}\n<!-- Visual {placeholder_num} End -->'
|
| 1189 |
except Exception as e:
|
|
@@ -1802,8 +1808,9 @@ Source:source_name [y]
|
|
| 1802 |
[[Visual Placeholder n:
|
| 1803 |
- Purpose of this visual is:...
|
| 1804 |
- Relevant content to generate it:
|
| 1805 |
-
o
|
| 1806 |
-
o
|
|
|
|
| 1807 |
o ...
|
| 1808 |
- Message to convey: ...
|
| 1809 |
]]
|
|
@@ -1840,6 +1847,7 @@ with:
|
|
| 1840 |
- n as the reference number,
|
| 1841 |
- source_name as the full name of the main source used and
|
| 1842 |
- y as the source reference in the reference table.
|
|
|
|
| 1843 |
Important note for graph placeholders:
|
| 1844 |
- on the line before [[...]] mention the source with the reference number [x] in the form: ""Source: abc [n]" - only one source should be mentioned
|
| 1845 |
- use p tag for the source and source reference number
|
|
|
|
| 1 |
# =============================================================================
|
| 2 |
# By T.Sakai / G.Huet
|
| 3 |
# =============================================================================
|
|
|
|
| 4 |
import os
|
| 5 |
import time
|
| 6 |
import io
|
|
|
|
| 929 |
|
| 930 |
try:
|
| 931 |
visual_html = generate_graph_snippet(instructions, context, initial_query, crumbs)
|
| 932 |
+
prompt_improve = f"Based on the instructions:\n{instructions}\n\nThe context:\n{context}\n\nThe knowledge crumbs:\n{crumbs}\n\nProvide a refined version to this graph code:\n{visual_html}\n\nThe improved result should be EXACTLY in the same html format (no introduction, no conclusion, no code fences)."
|
| 933 |
+
visual_html = openai_call(prompt_improve, model="o3-mini", max_tokens=10000)
|
| 934 |
+
visual_html = visual_html.strip().strip("```").strip()
|
| 935 |
+
|
| 936 |
return f'<!-- Graph {placeholder_num} Start -->\n<div class="graph-container" style="margin:20px 0;">\n{visual_html}\n</div>\n<!-- Graph {placeholder_num} End -->'
|
| 937 |
except Exception as e:
|
| 938 |
logging.error(f"Graph {placeholder_num} failed: {str(e)}")
|
|
|
|
| 1187 |
|
| 1188 |
try:
|
| 1189 |
visual_html = generate_visual_snippet(instructions, context, initial_query, crumbs)
|
| 1190 |
+
prompt_improve = f"Based on the instructions:\n{instructions}\n\nThe context:\n{context}\n\nThe knowledge crumbs:\n{crumbs}\n\nProvide a refined version to this visual code:\n{visual_html}\n\nThe improved result should be EXACTLY in the same html format (no introduction, no conclusion, no code fences)."
|
| 1191 |
+
visual_html = openai_call(prompt_improve, model="o3-mini", max_tokens=10000)
|
| 1192 |
+
visual_html = visual_html.strip().strip("```").strip()
|
| 1193 |
# Add error boundary and logging
|
| 1194 |
return f'<!-- Visual {placeholder_num} Start -->\n{visual_html}\n<!-- Visual {placeholder_num} End -->'
|
| 1195 |
except Exception as e:
|
|
|
|
| 1808 |
[[Visual Placeholder n:
|
| 1809 |
- Purpose of this visual is:...
|
| 1810 |
- Relevant content to generate it:
|
| 1811 |
+
o ex: arguments
|
| 1812 |
+
o ex: lists of elements
|
| 1813 |
+
o ex: data points
|
| 1814 |
o ...
|
| 1815 |
- Message to convey: ...
|
| 1816 |
]]
|
|
|
|
| 1847 |
- n as the reference number,
|
| 1848 |
- source_name as the full name of the main source used and
|
| 1849 |
- y as the source reference in the reference table.
|
| 1850 |
+
- the table containing all the required data has to include data points FROM the learnings / results from the search below
|
| 1851 |
Important note for graph placeholders:
|
| 1852 |
- on the line before [[...]] mention the source with the reference number [x] in the form: ""Source: abc [n]" - only one source should be mentioned
|
| 1853 |
- use p tag for the source and source reference number
|