pratham0011
commited on
Commit
β’
0f0b4f7
1
Parent(s):
6274649
Update streamlit_app.py
Browse files- streamlit_app.py +0 -115
streamlit_app.py
CHANGED
@@ -1,118 +1,3 @@
|
|
1 |
-
# import streamlit as st
|
2 |
-
# import requests
|
3 |
-
# import json
|
4 |
-
# import pandas as pd
|
5 |
-
|
6 |
-
# st.set_page_config(page_title="QueryMate: Text to SQL & CSV")
|
7 |
-
|
8 |
-
# st.markdown("# QueryMate: Text to SQL & CSV π¬ποΈ")
|
9 |
-
# st.markdown('''Welcome to QueryMate, your friendly assistant for converting natural language queries into SQL statements and CSV outputs!
|
10 |
-
# Let's get started with your data queries!''')
|
11 |
-
|
12 |
-
# # Load chat history
|
13 |
-
# def load_chat_history():
|
14 |
-
# try:
|
15 |
-
# with open('chat_history.json', 'r') as f:
|
16 |
-
# return json.load(f)
|
17 |
-
# except FileNotFoundError:
|
18 |
-
# return []
|
19 |
-
|
20 |
-
# def save_chat_history(history):
|
21 |
-
# with open('chat_history.json', 'w') as f:
|
22 |
-
# json.dump(history, f)
|
23 |
-
|
24 |
-
# chat_history = load_chat_history()
|
25 |
-
|
26 |
-
# # Data source selection
|
27 |
-
# data_source = st.radio("Select Data Source:", ('SQL Database', 'Employee CSV'))
|
28 |
-
|
29 |
-
# # Predefined queries
|
30 |
-
# predefined_queries = {
|
31 |
-
# 'SQL Database': [
|
32 |
-
# 'Print all students',
|
33 |
-
# 'Count total number of students',
|
34 |
-
# 'List students in Data Science class'
|
35 |
-
# ],
|
36 |
-
# 'Employee CSV': [
|
37 |
-
# 'Print employees having the department id equal to 100',
|
38 |
-
# 'Count total number of employees',
|
39 |
-
# 'List Top 5 employees according to salary in descending order'
|
40 |
-
# ]
|
41 |
-
# }
|
42 |
-
|
43 |
-
# st.markdown(f"### Predefined Queries for {data_source}")
|
44 |
-
|
45 |
-
# # Create buttons for predefined queries
|
46 |
-
# for query in predefined_queries[data_source]:
|
47 |
-
# if st.button(query):
|
48 |
-
# st.session_state.predefined_query = query
|
49 |
-
|
50 |
-
# st.markdown("### Enter Your Question")
|
51 |
-
# question = st.text_input("Input: ", key="input", value=st.session_state.get('predefined_query', ''))
|
52 |
-
|
53 |
-
# # Submit button
|
54 |
-
# submit = st.button("Submit")
|
55 |
-
|
56 |
-
# if submit:
|
57 |
-
# # Send request to FastAPI backend
|
58 |
-
# response = requests.post("http://localhost:8000/query",
|
59 |
-
# json={"question": question, "data_source": data_source})
|
60 |
-
# if response.status_code == 200:
|
61 |
-
# data = response.json()
|
62 |
-
# st.markdown(f"## Generated {'SQL' if data_source == 'SQL Database' else 'Pandas'} Query")
|
63 |
-
# st.code(data['query'])
|
64 |
-
|
65 |
-
# st.markdown("## Query Results")
|
66 |
-
# result = data['result']
|
67 |
-
|
68 |
-
# if isinstance(result, list) and len(result) > 0:
|
69 |
-
# if isinstance(result[0], dict):
|
70 |
-
# # For CSV queries that return a list of dictionaries
|
71 |
-
# df = pd.DataFrame(result)
|
72 |
-
# st.dataframe(df)
|
73 |
-
# elif isinstance(result[0], list):
|
74 |
-
# # For SQL queries that return a list of lists
|
75 |
-
# df = pd.DataFrame(result)
|
76 |
-
# st.dataframe(df)
|
77 |
-
# else:
|
78 |
-
# # For single column results
|
79 |
-
# st.dataframe(pd.DataFrame(result, columns=['Result']))
|
80 |
-
# elif isinstance(result, dict):
|
81 |
-
# # For single row results
|
82 |
-
# st.table(result)
|
83 |
-
# else:
|
84 |
-
# # For scalar results or empty results
|
85 |
-
# st.write(result)
|
86 |
-
|
87 |
-
# if data_source == 'Employee CSV':
|
88 |
-
# st.markdown("## Available CSV Columns")
|
89 |
-
# st.write(data['columns'])
|
90 |
-
|
91 |
-
# # Update chat history
|
92 |
-
# chat_history.append(f"π¨βπ»({data_source}): {question}")
|
93 |
-
# chat_history.append(f"π€: {data['query']}")
|
94 |
-
# save_chat_history(chat_history)
|
95 |
-
# else:
|
96 |
-
# st.error(f"Error processing your request: {response.text}")
|
97 |
-
|
98 |
-
# # Clear the predefined query from session state
|
99 |
-
# st.session_state.pop('predefined_query', None)
|
100 |
-
|
101 |
-
# # Display chat history
|
102 |
-
# st.markdown("## Chat History")
|
103 |
-
# for message in chat_history:
|
104 |
-
# st.text(message)
|
105 |
-
|
106 |
-
# # Option to clear chat history
|
107 |
-
# if st.button("Clear Chat History"):
|
108 |
-
# chat_history.clear()
|
109 |
-
# save_chat_history(chat_history)
|
110 |
-
# st.success("Chat history cleared!")
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
import streamlit as st
|
117 |
import requests
|
118 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import pandas as pd
|