A sidebar drag-and-drop file uploader that lets users upload their own CSV files, which get registered as queryable DuckDB tables instantly. The LLM then sees the new schema and can generate queries against the user's data.
- Add
register_uploaded_csv(file_name, dataframe)function that:- Takes a filename and pandas DataFrame
- Derives table name from filename (strip .csv, sanitize)
- Registers it in the global DuckDB connection via
conn.register(table_name, df) - Returns the table name
- Add
remove_table(table_name)function for cleanup - Add
get_registered_tables()to list all current tables
- Add
st.file_uploaderin sidebar (after templates, before Engine toggle)- Accept
.csvfiles, allow multiple accept_multiple_files=True
- Accept
- On upload:
- Read each CSV into a pandas DataFrame
- Call
register_uploaded_csv()for each - Store uploaded table names in
st.session_state.uploaded_tables - Show success indicator with table name + row count
- Add a "Your Data" section showing currently loaded tables with remove buttons
- Reset
pipeline_resultandcurrent_appwhen data sources change (schema changed)
- Already dynamically calls
get_table_schema()andget_all_sample_data()per request - No changes needed — the schema injection is already dynamic
- The LLM will automatically see new tables in the prompt
- Add a default sensitivity level for unknown columns (default to "public")
- Update
COLUMN_SENSITIVITY_MAPlookup to return "public" for unrecognized columns - This ensures governance doesn't block queries on user-uploaded data
- Update
check_column_access()to treat columns not in COLUMN_SENSITIVITY_MAP as "public" - This way uploaded CSV columns pass governance without manual config
data/sample_data_loader.py— register/remove table functionsapp.py— sidebar upload UI + session state managementengine/governance.py— handle unknown columns gracefullyconfig.py— default sensitivity for unknown columns (optional, may just handle in governance.py)