npc0 commited on
Commit
f6451f5
1 Parent(s): 1152ce2

untilize streamlit support of pandasai

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import pandas as pd
3
  from pandasai import SmartDataframe
 
4
  from langchain_groq import ChatGroq
5
 
6
  llm = ChatGroq(
@@ -20,9 +21,10 @@ st.title("Conversation Analysis")
20
 
21
  # Introduction and Explanation
22
  st.markdown("""
23
- **Go beyond static visualizations!** This app lets you directly ask for the insights you need from Polis conversation data.
24
- Instead of being limited to a standard PCA chart, you can request custom plots and analyses using natural language.
25
- For example, try asking for: "**Show me a pie chart of the most common sentiment expressed in these comments.**"
 
26
  """)
27
 
28
  # Step 1: Choose conversation
@@ -41,7 +43,13 @@ url = (
41
 
42
  # Load data only if URL changes
43
  if st.session_state['pre_url'] != url:
44
- df = SmartDataframe(pd.read_csv(url, index_col=0), config={"llm": llm})
 
 
 
 
 
 
45
  st.session_state['df'] = df
46
  st.session_state['pre_url'] = url
47
 
 
1
  import streamlit as st
2
  import pandas as pd
3
  from pandasai import SmartDataframe
4
+ from pandasai.responses.streamlit_response import StreamlitResponse
5
  from langchain_groq import ChatGroq
6
 
7
  llm = ChatGroq(
 
21
 
22
  # Introduction and Explanation
23
  st.markdown("""
24
+ ## Go beyond static visualizations!
25
+ This app lets you directly ask for the insights you need from Polis conversation data.
26
+ Instead of being limited to a standard PCA chart, you can request custom plots and analyses using natural language.
27
+ > :bulb: For example, try asking for: "**Show me a pie chart of the most common sentiment expressed in these comments.**"
28
  """)
29
 
30
  # Step 1: Choose conversation
 
43
 
44
  # Load data only if URL changes
45
  if st.session_state['pre_url'] != url:
46
+ df = SmartDataframe(
47
+ pd.read_csv(url, index_col=0),
48
+ config={
49
+ "llm": llm,
50
+ "response_parser": StreamlitResponse
51
+ }
52
+ )
53
  st.session_state['df'] = df
54
  st.session_state['pre_url'] = url
55