NEXAS commited on
Commit
2cea047
1 Parent(s): f742910

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +87 -43
app.py CHANGED
@@ -1,45 +1,89 @@
1
  import streamlit as st
2
- from main import datachat as dc
3
-
4
- st.title("Data-Engineers-Helper")
5
-
6
- data_file = r".\world_population_data.csv"
7
- uploaded_file = st.file_uploader("Choose a file")
8
- # Write the uploaded file to a specific location
9
- if uploaded_file is not None:
10
- with open(data_file, "wb") as f:
11
- f.write(uploaded_file.read())
12
-
13
- #chat_object= dc(file_path='./data/employees.csv')
14
- chat_object= dc(file_path=data_file)
15
-
16
- # Initialize chat history
17
- if "messages" not in st.session_state:
18
- st.session_state.messages = []
19
-
20
- # Display chat messages from history on app rerun
21
- for message in st.session_state.messages:
22
- if message["role"] == 'user':
23
- with st.chat_message(message["role"]):
24
- st.markdown(message["content"])
25
- if message["role"] == 'assistant':
26
- with st.chat_message(message["role"]):
27
- st.dataframe(message["content"],hide_index=True)
28
-
29
-
30
- # React to user input
31
- if prompt := st.chat_input("What is up?"):
32
- # Display user message in chat message container
33
- with st.chat_message("user"):
34
- st.markdown(prompt)
35
- # Add user message to chat history
36
- st.session_state.messages.append({"role": "user", "content": prompt})
37
-
38
- response = chat_object.data_ops(prompt)
39
- # Display assistant response in chat message container
40
- with st.chat_message("assistant"):
41
- #st.markdown(response)
42
- st.dataframe(response,hide_index=True)
43
- # Add assistant response to chat history
44
- st.session_state.messages.append({"role": "assistant", "content": response})
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ def intro():
4
+ st.write("# Data Engineers Helper ✨")
5
+ st.sidebar.success("Navigate Here ⏬.")
6
+
7
+ st.markdown(
8
+ """
9
+ ## Data Engineers Helper
10
+
11
+ This project aims to empower data engineers with the assistance of large language models (LLMs). It provides an interactive application where users can perform basic data engineering tasks through prompts and data upload functionalities.
12
+
13
+ ### Key functionalities:
14
+
15
+ * **Prompt-based Data Manipulation:** Utilize LLMs to automate data manipulation tasks by providing clear prompts. The LLM can understand and generate Python code to perform actions like filtering, aggregation, or transformation on your data.
16
+ * **Flexible Data Handling:** Upload various datasets in supported formats (e.g., CSV, Excel) for the LLM to analyze and manipulate based on your prompts.
17
+ * **Future: Automating Data Analysis:** We're actively developing an agent similar to AutoGPT, specifically designed for data analysis. This agent will assist users with tasks like:
18
+ * Identifying patterns and trends within datasets.
19
+ * Generating data visualizations based on user queries.
20
+ * Formulating data analysis questions and suggesting appropriate approaches.
21
+
22
+ ### Collaboration Opportunities:
23
+
24
+ We're open to collaboration with individuals and teams interested in:
25
+
26
+ * **LLM Integration:** Expertise in integrating LLMs for data engineering tasks is highly valuable.
27
+ * **Data Analysis Automation:** Sharing knowledge and collaborating on building the data analysis agent would significantly accelerate its development.
28
+ * **Usability Enhancements:** We welcome suggestions to improve the user experience and make the application more intuitive for data engineers.
29
+
30
+ **By combining LLM capabilities with a user-friendly interface, Data Engineers Helper strives to streamline data engineering workflows and empower users to focus on more complex tasks.**
31
+
32
+ **Let's work together to revolutionize the way data engineers approach their daily work! **
33
+
34
+ **Feel free to reach out if you have any questions or are interested in collaborating on this project. ✉️** [Contact us](mailto:xyzash568@gmail.com)
35
+
36
+
37
+ """
38
+ )
39
+
40
+ def data_frame_demo():
41
+ from main import datachat as dc
42
+ st.title("Data Engineer's Helper")
43
+
44
+ data_file = r"C./world_population_data.csv"
45
+ uploaded_file = st.file_uploader("Choose a file")
46
+ # Write the uploaded file to a specific location
47
+ if uploaded_file is not None:
48
+ with open(data_file, "wb") as f:
49
+ f.write(uploaded_file.read())
50
+
51
+ chat_object = dc(file_path=data_file)
52
+
53
+ # Initialize chat history
54
+ if "messages" not in st.session_state:
55
+ st.session_state.messages = []
56
+
57
+ # Display chat messages from history on app rerun
58
+ for message in st.session_state.messages:
59
+ if message["role"] == 'user':
60
+ with st.chat_message(message["role"]):
61
+ st.markdown(message["content"])
62
+ if message["role"] == 'assistant':
63
+ with st.chat_message(message["role"]):
64
+ st.dataframe(message["content"], hide_index=True)
65
+
66
+ # React to user input
67
+ if prompt := st.chat_input("What is up?"):
68
+ # Display user message in chat message container
69
+ with st.chat_message("user"):
70
+ st.markdown(prompt)
71
+ # Add user message to chat history
72
+ st.session_state.messages.append({"role": "user", "content": prompt})
73
+
74
+ response = chat_object.data_ops(prompt)
75
+ # Display assistant response in chat message container
76
+ with st.chat_message("assistant"):
77
+ st.dataframe(response, hide_index=True)
78
+ # Add assistant response to chat history
79
+ st.session_state.messages.append({"role": "assistant", "content": response})
80
+
81
+ # Dictionary mapping page names to their respective functions
82
+ page_names_to_funcs = {
83
+ "About": intro,
84
+ "Data Engineers Helper": data_frame_demo
85
+ }
86
+
87
+ # Select demo from sidebar
88
+ demo_name = st.sidebar.selectbox("Choose a page", page_names_to_funcs.keys())
89
+ page_names_to_funcs[demo_name]()