Spaces:
Sleeping
Sleeping
Initial commit with full functionality extend app
Browse files
app.py
CHANGED
|
@@ -60,26 +60,22 @@ def update_button_state(url: str) -> Dict:
|
|
| 60 |
|
| 61 |
with gr.Blocks(title="Smart Web Analyzer Plus", theme=gr.themes.Soft()) as demo:
|
| 62 |
# Header
|
| 63 |
-
gr.Markdown(
|
| 64 |
-
|
| 65 |
-
# π Smart Web Analyzer Plus
|
| 66 |
-
Analyze web content using AI to extract summaries, determine sentiment, and identify topics.
|
| 67 |
-
"""
|
| 68 |
-
)
|
| 69 |
|
| 70 |
# Input Section
|
| 71 |
with gr.Row():
|
| 72 |
-
with gr.Column(scale=
|
| 73 |
url_input = gr.Textbox(
|
| 74 |
label="Enter URL",
|
| 75 |
placeholder="https://example.com",
|
| 76 |
show_label=True
|
| 77 |
)
|
| 78 |
with gr.Column(scale=2):
|
| 79 |
-
|
| 80 |
choices=["summarize", "sentiment", "topics"],
|
| 81 |
label="Analysis Types",
|
| 82 |
-
value=["summarize"],
|
| 83 |
show_label=True
|
| 84 |
)
|
| 85 |
with gr.Column(scale=1):
|
|
@@ -89,29 +85,25 @@ with gr.Blocks(title="Smart Web Analyzer Plus", theme=gr.themes.Soft()) as demo:
|
|
| 89 |
interactive=False
|
| 90 |
)
|
| 91 |
|
| 92 |
-
#
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
sentiment_output = gr.Markdown()
|
| 100 |
-
with gr.TabItem("π Topics"):
|
| 101 |
-
topics_output = gr.Markdown()
|
| 102 |
|
| 103 |
# Loading indicator
|
| 104 |
-
|
| 105 |
-
status = gr.Markdown("")
|
| 106 |
|
| 107 |
# Example Section
|
| 108 |
gr.Examples(
|
|
|
|
| 109 |
examples=[
|
| 110 |
["https://www.bbc.com/news/technology-67881954", ["summarize", "sentiment"]],
|
| 111 |
["https://arxiv.org/html/2312.17296v1", ["topics", "summarize"]]
|
| 112 |
],
|
| 113 |
-
inputs=[url_input,
|
| 114 |
-
label="Try these examples"
|
| 115 |
)
|
| 116 |
|
| 117 |
# Event Handlers
|
|
@@ -123,10 +115,10 @@ with gr.Blocks(title="Smart Web Analyzer Plus", theme=gr.themes.Soft()) as demo:
|
|
| 123 |
)
|
| 124 |
|
| 125 |
def on_analyze_start():
|
| 126 |
-
return gr.update(value="β³ Analysis in progress...")
|
| 127 |
|
| 128 |
def on_analyze_end():
|
| 129 |
-
return gr.update(value="")
|
| 130 |
|
| 131 |
analyze_btn.click(
|
| 132 |
fn=on_analyze_start,
|
|
@@ -134,12 +126,12 @@ with gr.Blocks(title="Smart Web Analyzer Plus", theme=gr.themes.Soft()) as demo:
|
|
| 134 |
queue=False
|
| 135 |
).then(
|
| 136 |
fn=lambda url, m: format_results(analyzer.analyze(url, m)),
|
| 137 |
-
inputs=[url_input,
|
| 138 |
outputs=[
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
]
|
| 144 |
).then(
|
| 145 |
fn=on_analyze_end,
|
|
@@ -148,7 +140,6 @@ with gr.Blocks(title="Smart Web Analyzer Plus", theme=gr.themes.Soft()) as demo:
|
|
| 148 |
|
| 149 |
if __name__ == "__main__":
|
| 150 |
demo.launch(
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
server_port=7860 # Default Gradio port
|
| 154 |
)
|
|
|
|
| 60 |
|
| 61 |
with gr.Blocks(title="Smart Web Analyzer Plus", theme=gr.themes.Soft()) as demo:
|
| 62 |
# Header
|
| 63 |
+
gr.Markdown("# π Smart Web Analyzer Plus")
|
| 64 |
+
gr.Markdown("Analyze web content using AI to extract summaries, determine sentiment, and identify topics.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
# Input Section
|
| 67 |
with gr.Row():
|
| 68 |
+
with gr.Column(scale=3):
|
| 69 |
url_input = gr.Textbox(
|
| 70 |
label="Enter URL",
|
| 71 |
placeholder="https://example.com",
|
| 72 |
show_label=True
|
| 73 |
)
|
| 74 |
with gr.Column(scale=2):
|
| 75 |
+
analysis_types = gr.CheckboxGroup(
|
| 76 |
choices=["summarize", "sentiment", "topics"],
|
| 77 |
label="Analysis Types",
|
| 78 |
+
value=["summarize"],
|
| 79 |
show_label=True
|
| 80 |
)
|
| 81 |
with gr.Column(scale=1):
|
|
|
|
| 85 |
interactive=False
|
| 86 |
)
|
| 87 |
|
| 88 |
+
# Content display with single row of tabs
|
| 89 |
+
output_tabs = gr.Tabs([
|
| 90 |
+
gr.Tab("π Clean Text", gr.Markdown(label="Clean Text")),
|
| 91 |
+
gr.Tab("π Summary", gr.Markdown(label="Summary")),
|
| 92 |
+
gr.Tab("π Sentiment", gr.Markdown(label="Sentiment")),
|
| 93 |
+
gr.Tab("π Topics", gr.Markdown(label="Topics"))
|
| 94 |
+
])
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
# Loading indicator
|
| 97 |
+
status = gr.Markdown(visible=False)
|
|
|
|
| 98 |
|
| 99 |
# Example Section
|
| 100 |
gr.Examples(
|
| 101 |
+
label="Try these examples",
|
| 102 |
examples=[
|
| 103 |
["https://www.bbc.com/news/technology-67881954", ["summarize", "sentiment"]],
|
| 104 |
["https://arxiv.org/html/2312.17296v1", ["topics", "summarize"]]
|
| 105 |
],
|
| 106 |
+
inputs=[url_input, analysis_types]
|
|
|
|
| 107 |
)
|
| 108 |
|
| 109 |
# Event Handlers
|
|
|
|
| 115 |
)
|
| 116 |
|
| 117 |
def on_analyze_start():
|
| 118 |
+
return gr.update(value="β³ Analysis in progress...", visible=True)
|
| 119 |
|
| 120 |
def on_analyze_end():
|
| 121 |
+
return gr.update(value="", visible=False)
|
| 122 |
|
| 123 |
analyze_btn.click(
|
| 124 |
fn=on_analyze_start,
|
|
|
|
| 126 |
queue=False
|
| 127 |
).then(
|
| 128 |
fn=lambda url, m: format_results(analyzer.analyze(url, m)),
|
| 129 |
+
inputs=[url_input, analysis_types],
|
| 130 |
outputs=[
|
| 131 |
+
output_tabs.select(0), # Clean Text
|
| 132 |
+
output_tabs.select(1), # Summary
|
| 133 |
+
output_tabs.select(2), # Sentiment
|
| 134 |
+
output_tabs.select(3) # Topics
|
| 135 |
]
|
| 136 |
).then(
|
| 137 |
fn=on_analyze_end,
|
|
|
|
| 140 |
|
| 141 |
if __name__ == "__main__":
|
| 142 |
demo.launch(
|
| 143 |
+
server_name="0.0.0.0",
|
| 144 |
+
server_port=7860
|
|
|
|
| 145 |
)
|