Spaces:
Sleeping
Sleeping
DrishtiSharma
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import pandas as pd
|
|
3 |
import sqlite3
|
4 |
import tempfile
|
5 |
from fpdf import FPDF
|
|
|
6 |
import os
|
7 |
import re
|
8 |
import json
|
@@ -436,6 +437,24 @@ def escape_markdown(text):
|
|
436 |
escape_chars = r"(\*|_|`|~)"
|
437 |
return re.sub(escape_chars, r"\\\1", text)
|
438 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
# SQL-RAG Analysis
|
440 |
if st.session_state.df is not None:
|
441 |
temp_dir = tempfile.TemporaryDirectory()
|
|
|
3 |
import sqlite3
|
4 |
import tempfile
|
5 |
from fpdf import FPDF
|
6 |
+
import time
|
7 |
import os
|
8 |
import re
|
9 |
import json
|
|
|
437 |
escape_chars = r"(\*|_|`|~)"
|
438 |
return re.sub(escape_chars, r"\\\1", text)
|
439 |
|
440 |
+
|
441 |
+
def generate_report(query, crew_report, result_container, progress_bar, step):
|
442 |
+
progress_bar.progress(step, text="π Generating Analysis Report...")
|
443 |
+
report_inputs = {"query": query + " Provide detailed analysis but DO NOT include Conclusion."}
|
444 |
+
result_container['report'] = crew_report.kickoff(inputs=report_inputs)
|
445 |
+
progress_bar.progress(step + 1, text="β
Analysis Report Ready!")
|
446 |
+
|
447 |
+
def generate_conclusion(query, crew_conclusion, result_container, progress_bar, step):
|
448 |
+
progress_bar.progress(step, text="π Crafting Conclusion...")
|
449 |
+
conclusion_inputs = {"query": query + " Provide ONLY the most important insights in 3-5 concise lines."}
|
450 |
+
result_container['conclusion'] = crew_conclusion.kickoff(inputs=conclusion_inputs)
|
451 |
+
progress_bar.progress(step + 1, text="β
Conclusion Ready!")
|
452 |
+
|
453 |
+
def generate_visuals(query, df, llm, result_container, progress_bar, step):
|
454 |
+
progress_bar.progress(step, text="π Creating Visualizations...")
|
455 |
+
result_container['visuals'] = ask_gpt4o_for_visualization(query, df, llm)
|
456 |
+
progress_bar.progress(step + 1, text="β
Visualizations Ready!")
|
457 |
+
|
458 |
# SQL-RAG Analysis
|
459 |
if st.session_state.df is not None:
|
460 |
temp_dir = tempfile.TemporaryDirectory()
|