from utils import TEMP_DIR, message_dict import gradio as gr import templates.data_file as data_file, templates.sql_db as sql_db import os from getpass import getpass from dotenv import load_dotenv load_dotenv() def delete_db(req: gr.Request): import shutil dir_path = TEMP_DIR / str(req.session_hash) if os.path.exists(dir_path): shutil.rmtree(dir_path) message_dict[req.session_hash] = {} if "OPENAI_API_KEY" not in os.environ: os.environ["OPENAI_API_KEY"] = getpass("Enter OpenAI API key:") css= ".file_marker .large{min-height:50px !important;} .padding{padding:0;} .description_component{overflow:visible !important;}" head = """ Virtual Data Analyst """ theme = gr.themes.Base(primary_hue="sky", secondary_hue="slate",font=[gr.themes.GoogleFont("Inter"), "Inter", "sans-serif"]).set( button_primary_background_fill="#3B82F6", button_secondary_background_fill="#6B7280", ) from pathlib import Path gr.set_static_paths(paths=[Path.cwd().absolute()/"assets"]) with gr.Blocks(theme=theme, css=css, head=head, delete_cache=(3600,3600)) as demo: header = gr.HTML("""

Virtual Data Analyst

A powerful tool for data analysis, visualizations, and insights

Advanced Analytics

Run SQL queries, perform regressions, and analyze results with ease

Rich Visualizations

Create scatter plots, line charts, pie charts, and more

Automated Insights

Get instant insights and recommendations for your data

""") with gr.Tab("Data File"): data_file.demo.render() with gr.Tab("SQL Database"): sql_db.demo.render() footer = gr.HTML(""" """) demo.unload(delete_db) ## Uncomment the line below to launch the chat app with UI demo.launch(debug=True, allowed_paths=["temp/","assets/"])