Spaces:
Paused
Paused
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,6 +1,49 @@
|
|
| 1 |
-
from smolagents import launch_gradio_demo
|
| 2 |
-
from tool import SimpleTool
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from smolagents import load_tool
|
| 4 |
+
import json
|
| 5 |
|
| 6 |
+
analyzer = load_tool("MHamdan/web-analyzer", trust_remote_code=True)
|
| 7 |
+
|
| 8 |
+
def create_interface():
|
| 9 |
+
with gr.Blocks(title="Web Content Analyzer") as iface:
|
| 10 |
+
gr.Markdown("# 🌐 Web Content Analyzer")
|
| 11 |
+
gr.Markdown("""
|
| 12 |
+
Get AI-powered analysis of any webpage:
|
| 13 |
+
* 📝 Smart Summary
|
| 14 |
+
* 😊 Sentiment Analysis
|
| 15 |
+
* 📊 Content Statistics
|
| 16 |
+
""")
|
| 17 |
+
|
| 18 |
+
url_input = gr.Textbox(
|
| 19 |
+
label="Webpage URL",
|
| 20 |
+
placeholder="https://example.com"
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
analyze_btn = gr.Button("Analyze")
|
| 24 |
+
output = gr.JSON(label="Analysis Results")
|
| 25 |
+
|
| 26 |
+
# Examples
|
| 27 |
+
examples = [
|
| 28 |
+
["https://www.artificialintelligence-news.com/2024/02/14/openai-anthropic-google-white-house-red-teaming/"],
|
| 29 |
+
["https://www.artificialintelligence-news.com/2024/02/13/ai-21-labs-wordtune-chatgpt-plugin/"]
|
| 30 |
+
]
|
| 31 |
+
|
| 32 |
+
gr.Examples(
|
| 33 |
+
examples=examples,
|
| 34 |
+
inputs=url_input,
|
| 35 |
+
outputs=output,
|
| 36 |
+
fn=analyzer,
|
| 37 |
+
cache_examples=True
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
analyze_btn.click(
|
| 41 |
+
fn=analyzer,
|
| 42 |
+
inputs=url_input,
|
| 43 |
+
outputs=output
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
return iface
|
| 47 |
+
|
| 48 |
+
demo = create_interface()
|
| 49 |
+
demo.launch()
|