Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,217 +1,65 @@
|
|
1 |
import streamlit as st
|
2 |
-
# import wikipedia
|
3 |
-
from streamlit_lottie import st_lottie
|
4 |
-
import regex as re
|
5 |
-
from streamlit_js_eval import streamlit_js_eval
|
6 |
-
# from common.utils import *
|
7 |
-
from data_collector import *
|
8 |
-
# from langchain_community.llms import Ollama
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
#
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
if str(schema)!=str({}):
|
74 |
-
tabs = st.tabs(["Schema","Data Generation"])
|
75 |
-
with tabs[0]:
|
76 |
-
if str(schema)!=str({}):
|
77 |
-
|
78 |
-
schema_column1,schema_column2 = st.columns(2)
|
79 |
-
with schema_column1:
|
80 |
-
edited_df = st.data_editor([str(i) for index,i in enumerate(schema)],hide_index=True,use_container_width=True,num_rows='dynamic',height=int(screen_height/3))
|
81 |
-
|
82 |
-
with schema_column2:
|
83 |
-
number = st.number_input("Number of rows",min_value=1,max_value=1000,value=10)
|
84 |
-
if number!=condition_capture['count'] and updated_schema:
|
85 |
-
condition_capture['count'] = number
|
86 |
-
|
87 |
-
|
88 |
-
with open("/home/user/app/animation/edit_file.json") as animate:
|
89 |
-
url_json=json.load(animate)
|
90 |
-
st_lottie(url_json,height = int(screen_height/3))
|
91 |
-
|
92 |
-
|
93 |
-
with tabs[1]:
|
94 |
-
with open("/home/user/app/animation/no data animation.json") as animate:
|
95 |
-
url_json=json.load(animate)
|
96 |
-
dataframe=st.empty()
|
97 |
-
|
98 |
-
if condition_capture['count']==0:
|
99 |
-
st_lottie(url_json,height = int(screen_height/3))
|
100 |
-
|
101 |
-
else:
|
102 |
-
smart_append=[]
|
103 |
-
if condition_capture['prev_schema'] != condition_capture['schema']:
|
104 |
-
condition_capture['prev_schema'] = condition_capture['schema']
|
105 |
-
condition_capture['current_append']={}
|
106 |
-
|
107 |
-
for text_indexing,store in enumerate(actual_value(textual_value,schema)):
|
108 |
-
dummy_value =dictionary_formatting(store)
|
109 |
-
for keys in dummy_value:
|
110 |
-
while len(dummy_value[keys])>=2:
|
111 |
-
dummy_value[keys].pop(0)
|
112 |
-
dummy_value = dictionary_formatting(dummy_value)
|
113 |
-
|
114 |
-
if dummy_value != None:
|
115 |
-
|
116 |
-
|
117 |
-
smart_append.append(dummy_value)
|
118 |
-
print(dummy_value)
|
119 |
-
for keys in dummy_value:
|
120 |
-
if keys not in condition_capture['current_append']:
|
121 |
-
condition_capture['current_append'][str(keys)]=[]
|
122 |
-
condition_capture['current_append'][str(keys)].append(str([i for i in dummy_value[keys]]))
|
123 |
-
dataframe.dataframe(condition_capture['current_append'])
|
124 |
-
|
125 |
-
|
126 |
-
if len(condition_capture['current_append'][[i for i in condition_capture['current_append']][-1]])>=condition_capture['count']:
|
127 |
-
start_page.progress(100, text="Operation completed.")
|
128 |
-
|
129 |
-
break
|
130 |
-
else:
|
131 |
-
|
132 |
-
start_page.progress((text_indexing + 1)*(100//condition_capture['count']), text="Operation in progress. Please wait.")
|
133 |
-
write.write(html_page[[i for i in html_page][text_indexing]],unsafe_allow_html=True)
|
134 |
-
|
135 |
-
# print(dummy_value)
|
136 |
-
# if smart_check(dummy_value)!=True:
|
137 |
-
# smart_value=verification(dummy_value)
|
138 |
-
# if statement(condition_capture['schema'],smart_value):
|
139 |
-
# st.dataframe(smart_value)
|
140 |
-
condition_capture['current_append']={}
|
141 |
-
if len(smart_append)==0:
|
142 |
-
|
143 |
-
ranger=len(condition_capture['current_append'][[i for i in condition_capture['current_append']][0]])
|
144 |
-
for indexing in range(ranger):
|
145 |
-
working_dict = {}
|
146 |
-
for j in condition_capture['current_append']:
|
147 |
-
|
148 |
-
working_dict[j]=condition_capture['current_append'][j][indexing][0]
|
149 |
-
smart_append.append(working_dict)
|
150 |
-
smart_movement = sorting(smart_append)
|
151 |
-
|
152 |
-
for keys in smart_movement:
|
153 |
-
value=eval(keys)
|
154 |
-
for keys in value:
|
155 |
-
if keys not in condition_capture['current_append']:
|
156 |
-
condition_capture['current_append'][str(keys)]=[]
|
157 |
-
condition_capture['current_append'][str(keys)].append([str(i) for i in value[keys]])
|
158 |
-
dataframe.dataframe(condition_capture['current_append'])
|
159 |
-
for indexing,j in enumerate(smart_movement):
|
160 |
-
try:
|
161 |
-
# Convert string to dictionary
|
162 |
-
dummy_value = eval(j)
|
163 |
-
|
164 |
-
# Process dictionary values
|
165 |
-
for key in dummy_value:
|
166 |
-
while len(dummy_value[key]) >= 2:
|
167 |
-
dummy_value[key].pop(0)
|
168 |
-
|
169 |
-
# Format dictionary
|
170 |
-
formatted = dictionary_formatting(dummy_value)
|
171 |
-
print(formatted)
|
172 |
-
# Verify and store result
|
173 |
-
verification_result = verification(formatted) if formatted else None
|
174 |
-
for j in verification_result:
|
175 |
-
if j in condition_capture['current_append']:
|
176 |
-
condition_capture['current_append'][j][indexing]=[str(i) for i in verification_result[j]]
|
177 |
-
dataframe.dataframe(condition_capture['current_append'])
|
178 |
-
|
179 |
-
except:
|
180 |
-
pass
|
181 |
-
|
182 |
-
if len(condition_capture['schema'])==0:
|
183 |
-
st.markdown(
|
184 |
-
"""
|
185 |
-
<div style="text-align: center; font-size: 50px; font-weight: bold; margin-top: 20px;">
|
186 |
-
Generate high-quality, realistic data effortlessly.
|
187 |
-
</div>
|
188 |
-
""",
|
189 |
-
unsafe_allow_html=True
|
190 |
-
)
|
191 |
-
newline_column1,newline_column2 = st.columns(2)
|
192 |
-
with newline_column2:
|
193 |
-
with open("/home/user/app/animation/Data_rocket.json") as animate:
|
194 |
-
url_json=json.load(animate)
|
195 |
-
st_lottie(url_json,height = int(screen_height/4))
|
196 |
-
with newline_column1:
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
# Instructions for the user
|
201 |
-
st.markdown("""
|
202 |
-
### How it Works:
|
203 |
-
- **Step 1:** Enter a prompt to generate data.
|
204 |
-
- **step 2:** Select the number of rows you want to generate and press start processing.
|
205 |
-
- **Step 3:** AI will use Wikipedia insights to create realistic outputs.
|
206 |
-
- **Key Feature:** Less hallucination, more accurate data.
|
207 |
-
""")
|
208 |
-
|
209 |
-
prompt = st.text_input(label="Please use prompt to generate data",value=condition_capture['prompt'])
|
210 |
-
if prompt != str(condition_capture['prompt']):
|
211 |
-
|
212 |
-
condition_capture['prompt'] = prompt
|
213 |
-
schema = schema_generator(prompt)
|
214 |
-
condition_capture['schema'] = schema
|
215 |
-
condition_capture['current_append']={}
|
216 |
-
|
217 |
-
st.rerun()
|
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
# Page config with icon and wide layout for more space
|
4 |
+
st.set_page_config(page_title="App Maintenance - Available Here", page_icon="🛠️", layout="centered")
|
5 |
+
|
6 |
+
# Hide default Streamlit style elements for cleaner look
|
7 |
+
st.markdown("""
|
8 |
+
<style>
|
9 |
+
#MainMenu {visibility: hidden;}
|
10 |
+
footer {visibility: hidden;}
|
11 |
+
header {visibility: hidden;}
|
12 |
+
body {
|
13 |
+
background: linear-gradient(135deg, #74ebd5 0%, #ACB6E5 100%);
|
14 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
15 |
+
}
|
16 |
+
.container {
|
17 |
+
text-align: center;
|
18 |
+
padding: 80px 20px;
|
19 |
+
border-radius: 15px;
|
20 |
+
background-color: rgba(255,255,255,0.9);
|
21 |
+
box-shadow: 0 8px 24px rgba(0,0,0,0.2);
|
22 |
+
max-width: 600px;
|
23 |
+
margin: auto;
|
24 |
+
}
|
25 |
+
.title {
|
26 |
+
font-size: 56px;
|
27 |
+
font-weight: 700;
|
28 |
+
color: #003366;
|
29 |
+
margin-bottom: 10px;
|
30 |
+
}
|
31 |
+
.subtitle {
|
32 |
+
font-size: 22px;
|
33 |
+
color: #555555;
|
34 |
+
margin-bottom: 40px;
|
35 |
+
}
|
36 |
+
.btn-primary {
|
37 |
+
background-color: #0066cc;
|
38 |
+
color: white !important;
|
39 |
+
padding: 18px 36px;
|
40 |
+
font-size: 20px;
|
41 |
+
font-weight: 600;
|
42 |
+
border-radius: 10px;
|
43 |
+
text-decoration: none;
|
44 |
+
box-shadow: 0 4px 12px rgba(0,102,204,0.3);
|
45 |
+
transition: all 0.3s ease;
|
46 |
+
display: inline-block;
|
47 |
+
}
|
48 |
+
.btn-primary:hover {
|
49 |
+
background-color: #004a99;
|
50 |
+
box-shadow: 0 6px 20px rgba(0,75,153,0.4);
|
51 |
+
color: #e0e0e0 !important;
|
52 |
+
}
|
53 |
+
</style>
|
54 |
+
""", unsafe_allow_html=True)
|
55 |
+
|
56 |
+
# Main container content
|
57 |
+
st.markdown("""
|
58 |
+
<div class="container">
|
59 |
+
<div class="title">🛠️ We're Improving Your Experience</div>
|
60 |
+
<div class="subtitle">
|
61 |
+
Our app is undergoing scheduled maintenance, but don't worry, <br>you can still explore!
|
62 |
+
</div>
|
63 |
+
<a class="btn-primary" href="https://humble-warm-mule.ngrok-free.app/" target="_blank">Live App</a>
|
64 |
+
</div>
|
65 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|