Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -168,31 +168,6 @@ def qa_summarise(selected_queries, qa_llm_model, text_field, data_df):
|
|
168 |
|
169 |
|
170 |
with gr.Blocks(fill_width=True) as demo:
|
171 |
-
# js = """
|
172 |
-
# async () => {
|
173 |
-
# // Load Twitter Widgets script
|
174 |
-
# const script = document.createElement("script");
|
175 |
-
# script.onload = () => console.log("Twitter Widgets.js loaded");
|
176 |
-
# script.src = "https://platform.twitter.com/widgets.js";
|
177 |
-
# document.head.appendChild(script);
|
178 |
-
|
179 |
-
# // Define a global function to reload Twitter widgets
|
180 |
-
# globalThis.reloadTwitterWidgets = (x) => {
|
181 |
-
# // Select the container where tweets are inserted
|
182 |
-
# const tweetContainer = document.getElementById("tweet-container");
|
183 |
-
|
184 |
-
# if (tweetContainer) {
|
185 |
-
# tweetContainer.innerHTML = ""; // Clear previous tweets
|
186 |
-
# }
|
187 |
-
|
188 |
-
# // Reload Twitter widgets
|
189 |
-
# if (window.twttr && twttr.widgets) {
|
190 |
-
# twttr.widgets.load();
|
191 |
-
# }
|
192 |
-
# };
|
193 |
-
# }
|
194 |
-
# """
|
195 |
-
|
196 |
demo.load(None,None,None,js=js)
|
197 |
|
198 |
event_models = ["jayebaku/distilbert-base-multilingual-cased-crexdata-relevance-classifier",
|
@@ -224,23 +199,23 @@ with gr.Blocks(fill_width=True) as demo:
|
|
224 |
T_predict_button = gr.Button("Start Prediction")
|
225 |
|
226 |
gr.Markdown("""Select an ID cell in dataframe to view Embedded tweet""")
|
227 |
-
T_tweetID = gr.Textbox()
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
231 |
T_data_filter = gr.Dropdown(visible=False)
|
232 |
-
T_tweet_embed = gr.HTML("""<div id="tweet-container"></div>""")
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
column_widths=["49%","17%","17%","17%"])
|
244 |
|
245 |
|
246 |
|
@@ -387,7 +362,7 @@ with gr.Blocks(fill_width=True) as demo:
|
|
387 |
reloadTwitterWidgets();
|
388 |
const tweetContainer = document.getElementById("tweet-container");
|
389 |
tweetContainer.innerHTML = "";
|
390 |
-
twttr.widgets.createTweet(x,tweetContainer,{theme: 'dark'});
|
391 |
}
|
392 |
|
393 |
"""
|
@@ -398,14 +373,8 @@ with gr.Blocks(fill_width=True) as demo:
|
|
398 |
outputs=[T_data, T_data_ss_state, T_data_filter]
|
399 |
)
|
400 |
|
401 |
-
# T_data.select(T_on_select, None, T_tweet_embed)#.then(fn=None, js="reloadTwitterWidgets()")
|
402 |
T_data.select(T_on_select, None, T_tweetID)
|
403 |
-
T_tweetID.change(fn=None, inputs=T_tweetID, outputs=None, js=m_js)
|
404 |
-
# T_data.select(
|
405 |
-
# fn=lambda: gr.update(value=""),
|
406 |
-
# outputs=T_tweet_embed).then(T_on_select, None, T_tweet_embed).then(fn=None, js="reloadTwitterWidgets()")
|
407 |
-
|
408 |
-
# T_tweet_embed.change(fn=None, scroll_to_output=True, js="reloadTwitterWidgets()")
|
409 |
|
410 |
@T_data_filter.input(inputs=[T_data_ss_state, T_data_filter], outputs=T_data)
|
411 |
def filter_df(df, filter):
|
|
|
168 |
|
169 |
|
170 |
with gr.Blocks(fill_width=True) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
demo.load(None,None,None,js=js)
|
172 |
|
173 |
event_models = ["jayebaku/distilbert-base-multilingual-cased-crexdata-relevance-classifier",
|
|
|
199 |
T_predict_button = gr.Button("Start Prediction")
|
200 |
|
201 |
gr.Markdown("""Select an ID cell in dataframe to view Embedded tweet""")
|
202 |
+
T_tweetID = gr.Textbox(visible=False)
|
203 |
+
|
204 |
+
with gr.Row():
|
205 |
+
with gr.Column(scale=4):
|
206 |
+
with gr.Group():
|
207 |
T_data_filter = gr.Dropdown(visible=False)
|
208 |
+
T_tweet_embed = gr.HTML("""<div id="tweet-container"></div>""")
|
209 |
+
|
210 |
+
with gr.Column(scale=6):
|
211 |
+
T_data = gr.DataFrame(headers=["Texts", "event_label", "model_score", "IDs"],
|
212 |
+
wrap=True,
|
213 |
+
show_fullscreen_button=True,
|
214 |
+
show_copy_button=True,
|
215 |
+
show_row_numbers=True,
|
216 |
+
show_search="filter",
|
217 |
+
max_height=1000,
|
218 |
+
column_widths=["49%","17%","17%","17%"])
|
|
|
219 |
|
220 |
|
221 |
|
|
|
362 |
reloadTwitterWidgets();
|
363 |
const tweetContainer = document.getElementById("tweet-container");
|
364 |
tweetContainer.innerHTML = "";
|
365 |
+
twttr.widgets.createTweet(x,tweetContainer,{theme: 'dark', dnt: true, align: 'center'});
|
366 |
}
|
367 |
|
368 |
"""
|
|
|
373 |
outputs=[T_data, T_data_ss_state, T_data_filter]
|
374 |
)
|
375 |
|
|
|
376 |
T_data.select(T_on_select, None, T_tweetID)
|
377 |
+
T_tweetID.change(fn=None, inputs=T_tweetID, outputs=None, js=m_js)
|
|
|
|
|
|
|
|
|
|
|
378 |
|
379 |
@T_data_filter.input(inputs=[T_data_ss_state, T_data_filter], outputs=T_data)
|
380 |
def filter_df(df, filter):
|