Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -12,26 +12,26 @@ HFTOKEN = os.environ["HF_TOKEN"]
|
|
12 |
|
13 |
|
14 |
|
15 |
-
js = """
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
"""
|
33 |
|
34 |
-
def T_on_select(evt: gr.SelectData):
|
35 |
if evt.index[1] == 3:
|
36 |
html = """<blockquote id="tweet-container" class="twitter-tweet" data-dnt="true" data-theme="dark">""" + \
|
37 |
f"""\n<a href="https://twitter.com/anyuser/status/{evt.value}"></a></blockquote>"""
|
@@ -168,30 +168,30 @@ def qa_summarise(selected_queries, qa_llm_model, text_field, data_df):
|
|
168 |
|
169 |
|
170 |
with gr.Blocks(fill_width=True) as demo:
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
|
196 |
demo.load(None,None,None,js=js)
|
197 |
|
@@ -390,7 +390,7 @@ with gr.Blocks(fill_width=True) as demo:
|
|
390 |
outputs=[T_data, T_data_ss_state, T_data_filter]
|
391 |
)
|
392 |
|
393 |
-
T_data.select(T_on_select,
|
394 |
# T_data.select(T_on_select, None, T_tweetID)
|
395 |
# T_tweetID.change(fn=None, inputs=[T_tweetID], outputs=None, js="reloadTwitterWidgets(x)")#.then(fn=None, inputs=T_tweetID, outputs=None, js="(x) => twttr.widgets.createTweet(x,document.getElementById('tweet-container'),{theme: 'dark'});")
|
396 |
# T_data.select(
|
|
|
12 |
|
13 |
|
14 |
|
15 |
+
# js = """
|
16 |
+
# async () => {
|
17 |
+
# // Load Twitter Widgets script
|
18 |
+
# const script = document.createElement("script");
|
19 |
+
# script.onload = () => console.log("Twitter Widgets.js loaded");
|
20 |
+
# script.src = "https://platform.twitter.com/widgets.js";
|
21 |
+
# document.head.appendChild(script);
|
22 |
+
|
23 |
+
# // Define a global function to reload Twitter widgets
|
24 |
+
# globalThis.reloadTwitterWidgets = () => {
|
25 |
+
# // Reload Twitter widgets
|
26 |
+
# if (window.twttr && twttr.widgets) {
|
27 |
+
# twttr.widgets.load();
|
28 |
+
# }
|
29 |
|
30 |
+
# };
|
31 |
+
# }
|
32 |
+
# """
|
33 |
|
34 |
+
def T_on_select(x, evt: gr.SelectData):
|
35 |
if evt.index[1] == 3:
|
36 |
html = """<blockquote id="tweet-container" class="twitter-tweet" data-dnt="true" data-theme="dark">""" + \
|
37 |
f"""\n<a href="https://twitter.com/anyuser/status/{evt.value}"></a></blockquote>"""
|
|
|
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 |
|
|
|
390 |
outputs=[T_data, T_data_ss_state, T_data_filter]
|
391 |
)
|
392 |
|
393 |
+
T_data.select(T_on_select, T_tweetID, T_tweet_embed, js="reloadTwitterWidgets(x)")#.then(fn=None, js="reloadTwitterWidgets()")
|
394 |
# T_data.select(T_on_select, None, T_tweetID)
|
395 |
# T_tweetID.change(fn=None, inputs=[T_tweetID], outputs=None, js="reloadTwitterWidgets(x)")#.then(fn=None, inputs=T_tweetID, outputs=None, js="(x) => twttr.widgets.createTweet(x,document.getElementById('tweet-container'),{theme: 'dark'});")
|
396 |
# T_data.select(
|