Spaces:
Sleeping
Sleeping
Incorporated pygwalker data visualization and file upload
Browse files- src/streamlit_app.py +20 -0
src/streamlit_app.py
CHANGED
@@ -5,12 +5,32 @@ from pygwalker.api.streamlit import StreamlitRenderer
|
|
5 |
import re
|
6 |
from typing import List, Any
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def main():
|
10 |
"""Streamlit App"""
|
11 |
|
12 |
st.set_page_config(layout="wide")
|
13 |
st.title("Analytics Agent")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
if __name__ == "__main__":
|
16 |
main()
|
|
|
5 |
import re
|
6 |
from typing import List, Any
|
7 |
|
8 |
+
@st.cache_resource
|
9 |
+
def getPipeline():
|
10 |
+
return pipeline("text-generation", model="nvidia/Llama-3.1-Nemotron-Nano-4B-v1.1")
|
11 |
+
|
12 |
+
@st.cache_resource
|
13 |
+
def get_pyg_renderer(df: pd.DataFrame):
|
14 |
+
return StreamlitRenderer(st.session_state.df)
|
15 |
+
|
16 |
+
pipe = getPipeline()
|
17 |
|
18 |
def main():
|
19 |
"""Streamlit App"""
|
20 |
|
21 |
st.set_page_config(layout="wide")
|
22 |
st.title("Analytics Agent")
|
23 |
+
|
24 |
+
file = st.file_uploader("Choose CSV", type=["csv"])
|
25 |
+
|
26 |
+
if file:
|
27 |
+
if("df" not in st.session_state) or (st.session_state.get("current_file") != file.name):
|
28 |
+
st.session_state.df = pd.read_csv(file)
|
29 |
+
st.session_state.current_file = file.name
|
30 |
+
|
31 |
+
pygApp = get_pyg_renderer(st.session_state.df)
|
32 |
+
pygApp.explorer(default_tab="data")
|
33 |
+
|
34 |
|
35 |
if __name__ == "__main__":
|
36 |
main()
|