Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,8 +36,9 @@ img {margin-bottom: -8px;}
|
|
36 |
<body class="w3-content w3-black" style="max-width:1500px;">
|
37 |
|
38 |
<!-- The App Section -->
|
39 |
-
|
40 |
-
|
|
|
41 |
<div class="w3-col">
|
42 |
<h1 class="w3-jumbo"><b>WatchTower 🐦🚧</b></h1>
|
43 |
<h1 class="w3-xxxlarge w3-text-blue"><b>Remove Unfavorable Tweets From Your Feed </b></h1>
|
@@ -103,7 +104,7 @@ import gradio as gr
|
|
103 |
import tweepy
|
104 |
|
105 |
# Setup the gradio block and add some generic CSS
|
106 |
-
block = gr.Blocks(
|
107 |
|
108 |
# Chat history variable used for the chatbot prompt on the 'getting started' page.
|
109 |
chat_history = []
|
@@ -118,7 +119,7 @@ def get_client_from_tokens(oauth_verifier, oauth_token):
|
|
118 |
'''
|
119 |
new_oauth1_user_handler = tweepy.OAuth1UserHandler(
|
120 |
consumer_token, consumer_secret,
|
121 |
-
callback="#https://hf.space/embed/User1342/WatchTower/"
|
122 |
)
|
123 |
new_oauth1_user_handler.request_token = {
|
124 |
"oauth_token": oauth_token,
|
@@ -348,7 +349,7 @@ def get_target_website():
|
|
348 |
'''
|
349 |
oauth1_user_handler = tweepy.OAuth1UserHandler(
|
350 |
consumer_token, consumer_secret,
|
351 |
-
callback="https://hf.space/embed/User1342/WatchTower/"
|
352 |
)
|
353 |
target_website = oauth1_user_handler.get_authorization_url(signin_with_twitter=True)
|
354 |
|
@@ -372,33 +373,27 @@ with block:
|
|
372 |
user_message = "Log in via Twitter and configure your blocking options above."
|
373 |
chat_history.append(["Welcome to Watchtower.", user_message])
|
374 |
gr.HTML(value=html_data)
|
375 |
-
with gr.Group()
|
376 |
-
with gr.Row().style(
|
377 |
with gr.Box():
|
378 |
#gr.Label(value="WatchTower", visible=True, interactive=False)
|
379 |
url_params = gr.JSON({}, visible=False, label="URL Params").style(
|
380 |
)
|
381 |
-
text_input = gr.Text(label="Input", visible=False).style(
|
382 |
-
|
383 |
-
)
|
384 |
-
text_output = gr.Text(label="Output", visible=False).style(
|
385 |
-
rounded=(False, True, True, False),
|
386 |
-
)
|
387 |
html_button = twitter_auth_button = gr.HTML(
|
388 |
value='<a href={}><img src="https://cdn.cms-twdigitalassets.com/content/dam/developer-twitter/auth-docs/sign-in-with-twitter-gray.png.twimg.1920.png" alt="Log In With Twitter"></a><br>'.format(
|
389 |
get_target_website())).style(
|
390 |
)
|
391 |
-
with gr.Row().style(
|
392 |
radio = gr.CheckboxGroup(value=["Violent", "Hate Speech"], choices=["Violent", "Hate Speech", "Misinformation"],
|
393 |
interactive=False, label="Behaviour To Block").style()
|
394 |
|
395 |
slider = gr.Slider(value=30, interactive=True, label="Threshold Confidence Tolerance")
|
396 |
|
397 |
-
chatbot = gr.Chatbot(
|
398 |
|
399 |
-
btn = gr.Button("Run WatchTower").style(full_width=True).style(
|
400 |
-
rounded=(True, True, True, True),
|
401 |
-
)
|
402 |
btn.click(fn=button_pressed, inputs=[slider, url_params],
|
403 |
outputs=[text_output, chatbot], _js=get_window_url_params)
|
404 |
gr.Markdown(
|
@@ -414,6 +409,8 @@ block.__enter__()
|
|
414 |
block.set_event_trigger(
|
415 |
event_name="load", fn=update_target_website, inputs=None, outputs=[html_button], no_target=True
|
416 |
)
|
|
|
417 |
block.attach_load_events()
|
|
|
418 |
# Launcg the page
|
419 |
block.launch(enable_queue = True)
|
|
|
36 |
<body class="w3-content w3-black" style="max-width:1500px;">
|
37 |
|
38 |
<!-- The App Section -->
|
39 |
+
|
40 |
+
<div class="w3-padding-large w3-white">
|
41 |
+
<div class="w3-row-padding-large">
|
42 |
<div class="w3-col">
|
43 |
<h1 class="w3-jumbo"><b>WatchTower 🐦🚧</b></h1>
|
44 |
<h1 class="w3-xxxlarge w3-text-blue"><b>Remove Unfavorable Tweets From Your Feed </b></h1>
|
|
|
104 |
import tweepy
|
105 |
|
106 |
# Setup the gradio block and add some generic CSS
|
107 |
+
block = gr.Blocks(css=".container { max-width: 800px; margin: auto; } h1 { margin: 0px; padding: 5px 0; line-height: 50px; font-size: 60pt; }.close-heading {margin: 0px; padding: 0px;} .close-heading p { margin: 0px; padding: 0px;}", title="WatchTower")
|
108 |
|
109 |
# Chat history variable used for the chatbot prompt on the 'getting started' page.
|
110 |
chat_history = []
|
|
|
119 |
'''
|
120 |
new_oauth1_user_handler = tweepy.OAuth1UserHandler(
|
121 |
consumer_token, consumer_secret,
|
122 |
+
callback="http://127.0.0.1:7860/'#https://hf.space/embed/User1342/WatchTower/"
|
123 |
)
|
124 |
new_oauth1_user_handler.request_token = {
|
125 |
"oauth_token": oauth_token,
|
|
|
349 |
'''
|
350 |
oauth1_user_handler = tweepy.OAuth1UserHandler(
|
351 |
consumer_token, consumer_secret,
|
352 |
+
callback="http://127.0.0.1:7860/"#"https://hf.space/embed/User1342/WatchTower/"
|
353 |
)
|
354 |
target_website = oauth1_user_handler.get_authorization_url(signin_with_twitter=True)
|
355 |
|
|
|
373 |
user_message = "Log in via Twitter and configure your blocking options above."
|
374 |
chat_history.append(["Welcome to Watchtower.", user_message])
|
375 |
gr.HTML(value=html_data)
|
376 |
+
with gr.Group():
|
377 |
+
with gr.Row().style(equal_height=True):
|
378 |
with gr.Box():
|
379 |
#gr.Label(value="WatchTower", visible=True, interactive=False)
|
380 |
url_params = gr.JSON({}, visible=False, label="URL Params").style(
|
381 |
)
|
382 |
+
text_input = gr.Text(label="Input", visible=False).style()
|
383 |
+
text_output = gr.Text(label="Output", visible=False).style()
|
|
|
|
|
|
|
|
|
384 |
html_button = twitter_auth_button = gr.HTML(
|
385 |
value='<a href={}><img src="https://cdn.cms-twdigitalassets.com/content/dam/developer-twitter/auth-docs/sign-in-with-twitter-gray.png.twimg.1920.png" alt="Log In With Twitter"></a><br>'.format(
|
386 |
get_target_website())).style(
|
387 |
)
|
388 |
+
with gr.Row().style(equal_height=True):
|
389 |
radio = gr.CheckboxGroup(value=["Violent", "Hate Speech"], choices=["Violent", "Hate Speech", "Misinformation"],
|
390 |
interactive=False, label="Behaviour To Block").style()
|
391 |
|
392 |
slider = gr.Slider(value=30, interactive=True, label="Threshold Confidence Tolerance")
|
393 |
|
394 |
+
chatbot = gr.Chatbot(label="Watchtower Output").style(color_map=["blue","grey"])
|
395 |
|
396 |
+
btn = gr.Button("Run WatchTower").style(full_width=True).style()
|
|
|
|
|
397 |
btn.click(fn=button_pressed, inputs=[slider, url_params],
|
398 |
outputs=[text_output, chatbot], _js=get_window_url_params)
|
399 |
gr.Markdown(
|
|
|
409 |
block.set_event_trigger(
|
410 |
event_name="load", fn=update_target_website, inputs=None, outputs=[html_button], no_target=True
|
411 |
)
|
412 |
+
|
413 |
block.attach_load_events()
|
414 |
+
|
415 |
# Launcg the page
|
416 |
block.launch(enable_queue = True)
|