mgbam commited on
Commit
b411743
Β·
verified Β·
1 Parent(s): 88d9841

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -8
app.py CHANGED
@@ -1,12 +1,14 @@
1
-
2
  import streamlit as st
3
  from agents.analytics_pipeline import analytics_coordinator
4
  import os
5
  from db_connector import fetch_data_from_db, list_tables, SUPPORTED_ENGINES
6
 
7
  st.set_page_config(page_title="BizIntel AI Ultra", layout="wide")
8
- st.title("πŸ“Š BizIntel AI Ultra - Business Intelligence Agent")
9
 
 
 
 
10
  input_source = st.radio("Select data source", ["Upload CSV", "Connect to SQL Database"])
11
  file_path = None
12
 
@@ -16,25 +18,50 @@ if input_source == "Upload CSV":
16
  file_path = os.path.join("data", uploaded_file.name)
17
  with open(file_path, "wb") as f:
18
  f.write(uploaded_file.read())
19
- st.success("File uploaded.")
20
 
21
  elif input_source == "Connect to SQL Database":
22
- engine = st.selectbox("Select database engine", SUPPORTED_ENGINES)
23
- conn_str = st.text_input("Connection string (SQLAlchemy format)")
24
  if conn_str:
25
  tables = list_tables(conn_str)
26
  if tables:
27
  table_name = st.selectbox("Choose a table", tables)
28
  if table_name:
29
  file_path = fetch_data_from_db(conn_str, table_name)
30
- st.success(f"Fetched table '{table_name}' as CSV.")
 
 
 
 
 
 
 
 
 
 
31
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  if file_path:
33
- st.info("Running analytics pipeline...")
 
34
  result = analytics_coordinator.run(input=file_path)
35
- st.subheader("Analysis & Strategy Report")
 
36
  st.text(result)
37
 
 
38
  if os.path.exists("sales_plot.png"):
39
  st.image("sales_plot.png", caption="Sales Trend", use_column_width=True)
40
  if os.path.exists("forecast_plot.png"):
 
 
1
  import streamlit as st
2
  from agents.analytics_pipeline import analytics_coordinator
3
  import os
4
  from db_connector import fetch_data_from_db, list_tables, SUPPORTED_ENGINES
5
 
6
  st.set_page_config(page_title="BizIntel AI Ultra", layout="wide")
7
+ st.title("πŸ“Š BizIntel AI Ultra – Business Intelligence Agent")
8
 
9
+ # ──────────────────────────────────────────────────────────────
10
+ # ❢ DATA SOURCE SELECTION (CSV or Database)
11
+ # ──────────────────────────────────────────────────────────────
12
  input_source = st.radio("Select data source", ["Upload CSV", "Connect to SQL Database"])
13
  file_path = None
14
 
 
18
  file_path = os.path.join("data", uploaded_file.name)
19
  with open(file_path, "wb") as f:
20
  f.write(uploaded_file.read())
21
+ st.success("CSV file uploaded βœ…")
22
 
23
  elif input_source == "Connect to SQL Database":
24
+ engine = st.selectbox("Database engine", SUPPORTED_ENGINES)
25
+ conn_str = st.text_input("SQLAlchemy connection string")
26
  if conn_str:
27
  tables = list_tables(conn_str)
28
  if tables:
29
  table_name = st.selectbox("Choose a table", tables)
30
  if table_name:
31
  file_path = fetch_data_from_db(conn_str, table_name)
32
+ st.success(f"Fetched **{table_name}** as CSV βœ…")
33
+
34
+ # ──────────────────────────────────────────────────────────────
35
+ # ❷ OPTIONAL IMAGE UPLOAD + PREVIEW
36
+ # ──────────────────────────────────────────────────────────────
37
+ st.markdown("---")
38
+ st.subheader("πŸ“· Optional: Upload an Image for Preview / Future Analysis")
39
+
40
+ uploaded_image = st.file_uploader(
41
+ "Upload an image (PNG orΒ JPG)", type=["png", "jpg", "jpeg"], key="img"
42
+ )
43
 
44
+ if uploaded_image is not None:
45
+ image_path = os.path.join("data", uploaded_image.name)
46
+ with open(image_path, "wb") as f:
47
+ f.write(uploaded_image.read())
48
+ st.image(image_path, caption="Uploaded Image", use_column_width=True)
49
+
50
+ # πŸ‘‰Β If you later want to pass the image to an agent, you can add code here
51
+ # e.g.Β result = image_analysis_agent.run(input=image_path)
52
+
53
+ # ──────────────────────────────────────────────────────────────
54
+ # ❸ RUN BUSINESS ANALYTICS PIPELINE
55
+ # ──────────────────────────────────────────────────────────────
56
  if file_path:
57
+ st.markdown("---")
58
+ st.info("Running analytics pipeline… ⏳")
59
  result = analytics_coordinator.run(input=file_path)
60
+
61
+ st.subheader("πŸ“ Analysis & Strategy Report")
62
  st.text(result)
63
 
64
+ # Display generated charts if they exist
65
  if os.path.exists("sales_plot.png"):
66
  st.image("sales_plot.png", caption="Sales Trend", use_column_width=True)
67
  if os.path.exists("forecast_plot.png"):