Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import uuid
|
2 |
import base64
|
3 |
import json
|
4 |
-
import streamlit
|
5 |
-
|
6 |
|
7 |
st.title("Ask Questions to Data")
|
8 |
st.markdown("##### Demo Application powered by sketch package")
|
@@ -10,7 +19,6 @@ st.sidebar.image("https://avatars.githubusercontent.com/u/106505054?s=200&v=4",
|
|
10 |
st.sidebar.title("About the Package used")
|
11 |
st.sidebar.markdown("##### Sketch is an AI code-writing assistant for pandas users that understands the context of the data, greatly improving the relevance of suggestions. Sketch is usable in seconds and doesn't require adding a plugin to IDE.")
|
12 |
|
13 |
-
|
14 |
st.sidebar.title("How it works:")
|
15 |
st.sidebar.markdown("##### Sketch uses efficient approximation algorithms (data sketches) to quickly summarize the data, and feed that information into language models. Right now, it does this by summarizing the columns and writing these summary statistics as additional context to be used by the code-writing prompt. In the future, the dev team hopes to feed these sketches directly into custom made data + language foundation models to get more accurate results.")
|
16 |
|
@@ -22,6 +30,9 @@ st.sidebar.markdown("##### Data Analysis: Data questions, Data Visualizations")
|
|
22 |
st.sidebar.caption("Github Repository: https://github.com/approximatelabs/sketch")
|
23 |
|
24 |
|
|
|
|
|
|
|
25 |
def upload_data_file():
|
26 |
st.session_state.file = None
|
27 |
st.session_state.df = None
|
@@ -50,34 +61,17 @@ if st.session_state.file is None:
|
|
50 |
upload_data_file()
|
51 |
|
52 |
|
53 |
-
|
54 |
-
|
55 |
def to_b64(data):
|
56 |
return base64.b64encode(json.dumps(data).encode("utf-8")).decode("utf-8")
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
if st.session_state.file is not None:
|
63 |
st.session_state.file.seek(0)
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
df = pd.read_csv(st.session_state.file)
|
70 |
|
71 |
st.header("Uploaded Data:")
|
72 |
st.dataframe(df)
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
with st.form("my_form"):
|
82 |
request_type = st.radio(
|
83 |
label="Selection Panel",
|
@@ -105,15 +99,4 @@ if st.session_state.file is not None:
|
|
105 |
st.code(answer1)
|
106 |
|
107 |
else:
|
108 |
-
st.write('Please upload data file in order to ask questions to it.')
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import asyncio
|
4 |
+
import random
|
5 |
+
|
6 |
+
loop = asyncio.new_event_loop()
|
7 |
+
asyncio.set_event_loop(loop)
|
8 |
+
|
9 |
+
import sketch
|
10 |
+
import streamlit.components.v1 as components
|
11 |
+
from IPython.display import HTML, display
|
12 |
import uuid
|
13 |
import base64
|
14 |
import json
|
|
|
|
|
15 |
|
16 |
st.title("Ask Questions to Data")
|
17 |
st.markdown("##### Demo Application powered by sketch package")
|
|
|
19 |
st.sidebar.title("About the Package used")
|
20 |
st.sidebar.markdown("##### Sketch is an AI code-writing assistant for pandas users that understands the context of the data, greatly improving the relevance of suggestions. Sketch is usable in seconds and doesn't require adding a plugin to IDE.")
|
21 |
|
|
|
22 |
st.sidebar.title("How it works:")
|
23 |
st.sidebar.markdown("##### Sketch uses efficient approximation algorithms (data sketches) to quickly summarize the data, and feed that information into language models. Right now, it does this by summarizing the columns and writing these summary statistics as additional context to be used by the code-writing prompt. In the future, the dev team hopes to feed these sketches directly into custom made data + language foundation models to get more accurate results.")
|
24 |
|
|
|
30 |
st.sidebar.caption("Github Repository: https://github.com/approximatelabs/sketch")
|
31 |
|
32 |
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
def upload_data_file():
|
37 |
st.session_state.file = None
|
38 |
st.session_state.df = None
|
|
|
61 |
upload_data_file()
|
62 |
|
63 |
|
|
|
|
|
64 |
def to_b64(data):
|
65 |
return base64.b64encode(json.dumps(data).encode("utf-8")).decode("utf-8")
|
66 |
|
|
|
|
|
|
|
|
|
67 |
if st.session_state.file is not None:
|
68 |
st.session_state.file.seek(0)
|
69 |
|
|
|
|
|
|
|
|
|
70 |
df = pd.read_csv(st.session_state.file)
|
71 |
|
72 |
st.header("Uploaded Data:")
|
73 |
st.dataframe(df)
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
with st.form("my_form"):
|
76 |
request_type = st.radio(
|
77 |
label="Selection Panel",
|
|
|
99 |
st.code(answer1)
|
100 |
|
101 |
else:
|
102 |
+
st.write('Please upload data file in order to ask questions to it.')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|