Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -221,7 +221,7 @@ crew = Crew(
|
|
221 |
)
|
222 |
|
223 |
# PDF Report Generation
|
224 |
-
def generate_pdf_report(result, charts=None, table_data=None, metadata=None):
|
225 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as temp_pdf:
|
226 |
pdf = FPDF()
|
227 |
pdf.add_page()
|
@@ -240,25 +240,37 @@ def generate_pdf_report(result, charts=None, table_data=None, metadata=None):
|
|
240 |
pdf.set_font("Arial", size=12)
|
241 |
pdf.multi_cell(0, 10, txt=result)
|
242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
if charts:
|
244 |
for chart_path in charts:
|
245 |
try:
|
246 |
pdf.add_page()
|
247 |
pdf.image(chart_path, x=10, y=20, w=180)
|
248 |
-
logging.info(f"Successfully included chart: {chart_path}")
|
249 |
except Exception as e:
|
250 |
-
logging.error(f"
|
251 |
|
|
|
252 |
if table_data:
|
253 |
pdf.add_page()
|
254 |
pdf.set_font("Arial", size=10)
|
255 |
-
pdf.cell(200, 10, txt="Consolidated Table:", ln=True, align="L")
|
256 |
for row in table_data:
|
257 |
pdf.cell(200, 10, txt=str(row), ln=True)
|
258 |
|
259 |
pdf.output(temp_pdf.name)
|
260 |
return temp_pdf.name
|
261 |
|
|
|
262 |
# Data Validation
|
263 |
def validate_analyst_output(analyst_output):
|
264 |
if not analyst_output:
|
|
|
221 |
)
|
222 |
|
223 |
# PDF Report Generation
|
224 |
+
def generate_pdf_report(result, charts=None, table_data=None, metadata=None, key_insights=None):
|
225 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as temp_pdf:
|
226 |
pdf = FPDF()
|
227 |
pdf.add_page()
|
|
|
240 |
pdf.set_font("Arial", size=12)
|
241 |
pdf.multi_cell(0, 10, txt=result)
|
242 |
|
243 |
+
# Insert Key Insights Section
|
244 |
+
if key_insights:
|
245 |
+
pdf.add_page()
|
246 |
+
pdf.set_font("Arial", size=14, style="B")
|
247 |
+
pdf.cell(200, 10, txt="Key Strategic Insights", ln=True)
|
248 |
+
pdf.ln(5)
|
249 |
+
pdf.set_font("Arial", size=12)
|
250 |
+
for insight in key_insights:
|
251 |
+
pdf.multi_cell(0, 10, txt=f"- {insight}")
|
252 |
+
|
253 |
+
# Insert Charts
|
254 |
if charts:
|
255 |
for chart_path in charts:
|
256 |
try:
|
257 |
pdf.add_page()
|
258 |
pdf.image(chart_path, x=10, y=20, w=180)
|
|
|
259 |
except Exception as e:
|
260 |
+
logging.error(f"Error including chart: {e}")
|
261 |
|
262 |
+
# Insert Tables
|
263 |
if table_data:
|
264 |
pdf.add_page()
|
265 |
pdf.set_font("Arial", size=10)
|
266 |
+
pdf.cell(200, 10, txt="Consolidated Data Table:", ln=True, align="L")
|
267 |
for row in table_data:
|
268 |
pdf.cell(200, 10, txt=str(row), ln=True)
|
269 |
|
270 |
pdf.output(temp_pdf.name)
|
271 |
return temp_pdf.name
|
272 |
|
273 |
+
|
274 |
# Data Validation
|
275 |
def validate_analyst_output(analyst_output):
|
276 |
if not analyst_output:
|