aiscientist commited on
Commit
60ac372
·
verified ·
1 Parent(s): 117e55f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -0
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit.components.v1 as components
3
+ import streamlit as st
4
+ from ydata_profiling import ProfileReport
5
+ from streamlit_pandas_profiling import st_profile_report
6
+ from langchain.llms.openai import OpenAI
7
+ from langchain_experimental.agents import create_csv_agent
8
+ from langchain.agents.agent_types import AgentType
9
+ import time
10
+ import os
11
+ from mitosheet.streamlit.v1 import spreadsheet
12
+ from pygwalker.api.streamlit import init_streamlit_comm, get_streamlit_html
13
+
14
+ st.set_page_config(
15
+ page_title="AI TOOL",
16
+ layout="wide"
17
+ )
18
+
19
+ def main():
20
+ st.sidebar.title("App Options")
21
+ option = st.sidebar.selectbox("Choose an option", ["View Instructions", "View Data","Data Profiling","Tableau AI", "CSV Chatbot"])
22
+
23
+ if option == "View Instructions":
24
+ show_instructions()
25
+ elif option == "Data Profiling":
26
+ uploaded_file = st.file_uploader("Upload CSV file", type=["csv"])
27
+ if uploaded_file is None:
28
+ st.warning("Please upload a CSV file.")
29
+ st.stop() # Stop execution if no file uploaded
30
+ else:
31
+ data_profiling(uploaded_file)
32
+ elif option == "CSV Chatbot":
33
+ openai_api_key = st.text_input("Enter your OpenAI API Key", type="password")
34
+ if not openai_api_key:
35
+ st.warning("You should have an OpenAI API key to continue. Get one at [OpenAI API Keys](https://platform.openai.com/api-keys)")
36
+ st.stop()
37
+ os.environ['OPENAI_API_KEY'] = openai_api_key
38
+ personal_assistant()
39
+ elif option == "View Data":
40
+ virtual_excel_sheet()
41
+ elif option == "Tableau AI":
42
+ tableau_ai()
43
+
44
+ def show_instructions():
45
+ st.title("Welcome to the AI TOOL!")
46
+ st.write("This tool offers several functionalities to help you analyze and work with your data.")
47
+ st.write("Please select an option from the sidebar to proceed:")
48
+ st.write("- **View Data:** Upload a CSV file and view its contents.")
49
+ st.write("- **Data Profiling:** Upload a CSV file to generate a data profiling report.")
50
+ st.write("- **CSV Chatbot:** Interact with a chatbot to get insights from your CSV data.")
51
+ st.write("- **Tableau AI:** Upload a CSV file to visualize it using Tableau AI.")
52
+ st.write("- **View Instructions:** View these instructions again.")
53
+
54
+ def data_profiling(uploaded_file):
55
+ st.title("Data Profiling App")
56
+
57
+ # Load the data
58
+ df = pd.read_csv(uploaded_file)
59
+
60
+ # Display the dataframe
61
+ st.dataframe(df)
62
+
63
+ # Generate and display the data profile report
64
+ pr = ProfileReport(df, title="Report")
65
+ st_profile_report(pr)
66
+
67
+ # Define other functions (personal_assistant, virtual_excel_sheet, tableau_ai) as before...
68
+
69
+ if __name__ == "__main__":
70
+ main()