dineshb commited on
Commit
fa47aab
·
verified ·
1 Parent(s): f8e45ae

Keep hosted AI Insights stable

Browse files

Select an evidence-grounded local analyst brief on Hugging Face while retaining Gemini support for unrestricted deployments.

Files changed (1) hide show
  1. app.py +23 -10
app.py CHANGED
@@ -10,7 +10,12 @@ import pandas as pd
10
  import plotly.express as px
11
  import streamlit as st
12
 
13
- from datapilot.analyst import dataframe_csv, gemini_dataset_summary, inspect_dataset
 
 
 
 
 
14
  from datapilot.config import get_settings
15
  from datapilot.data import SAMPLE_DATASETS, load_sample
16
  from datapilot.workflow import run_analysis
@@ -325,7 +330,12 @@ with explore:
325
  st.plotly_chart(fig, width="stretch")
326
 
327
  with ai_tab:
328
- st.markdown("#### Ask Gemini to interpret the computed evidence")
 
 
 
 
 
329
  st.caption(
330
  "AI interpretation based on dataset metadata and limited redacted samples. Verify against source documentation."
331
  )
@@ -338,14 +348,17 @@ with ai_tab:
338
  "Generate AI analyst brief",
339
  disabled=not bool(api_key) or ai_future is not None,
340
  ):
341
- st.session_state.ai_future = ai_executor().submit(
342
- gemini_dataset_summary,
343
- frame.copy(deep=True),
344
- profile,
345
- api_key,
346
- model,
347
- list(excluded),
348
- )
 
 
 
349
  st.rerun()
350
 
351
  ai_future = st.session_state.ai_future
 
10
  import plotly.express as px
11
  import streamlit as st
12
 
13
+ from datapilot.analyst import (
14
+ dataframe_csv,
15
+ evidence_dataset_summary,
16
+ gemini_dataset_summary,
17
+ inspect_dataset,
18
+ )
19
  from datapilot.config import get_settings
20
  from datapilot.data import SAMPLE_DATASETS, load_sample
21
  from datapilot.workflow import run_analysis
 
330
  st.plotly_chart(fig, width="stretch")
331
 
332
  with ai_tab:
333
+ hosted_evidence_mode = bool(os.getenv("SPACE_ID"))
334
+ st.markdown(
335
+ "#### Generate an evidence-grounded analyst brief"
336
+ if hosted_evidence_mode
337
+ else "#### Ask Gemini to interpret the computed evidence"
338
+ )
339
  st.caption(
340
  "AI interpretation based on dataset metadata and limited redacted samples. Verify against source documentation."
341
  )
 
348
  "Generate AI analyst brief",
349
  disabled=not bool(api_key) or ai_future is not None,
350
  ):
351
+ if hosted_evidence_mode:
352
+ st.session_state.ai_summary = evidence_dataset_summary(frame, profile)
353
+ else:
354
+ st.session_state.ai_future = ai_executor().submit(
355
+ gemini_dataset_summary,
356
+ frame.copy(deep=True),
357
+ profile,
358
+ api_key,
359
+ model,
360
+ list(excluded),
361
+ )
362
  st.rerun()
363
 
364
  ai_future = st.session_state.ai_future