web-analyzer / app.py
MHamdan's picture
Upload app.py with huggingface_hub
c40e4ff verified
raw
history blame
2.35 kB
import gradio as gr
from smolagents import load_tool
# Load the tool
web_analyzer = load_tool("MHamdan/web-analyzer", trust_remote_code=True)
def analyze_content(url, mode):
return web_analyzer(url, mode)
def create_interface():
with gr.Blocks(title="AI Web Analyzer") as iface:
gr.Markdown("# πŸ€– AI-Powered Web Content Analyzer")
gr.Markdown("""
## Features:
- πŸ“Š **Analyze**: Complete content analysis with AI summary
- πŸ“ **Summarize**: AI-generated multi-section summary
- 😊 **Sentiment**: Section-by-section sentiment analysis
- 🎯 **Topics**: AI topic classification
""")
with gr.Row():
with gr.Column():
url_input = gr.Textbox(
label="Webpage URL",
placeholder="Enter URL to analyze..."
)
mode = gr.Dropdown(
choices=["analyze", "summarize", "sentiment", "topics"],
label="Analysis Mode",
value="analyze"
)
submit_btn = gr.Button("Analyze Content", variant="primary")
with gr.Column():
output = gr.Textbox(
label="AI Analysis Results",
lines=15
)
# Example data
examples = [
["https://www.artificialintelligence-news.com/2024/02/14/openai-anthropic-google-white-house-red-teaming/", "analyze"],
["https://www.artificialintelligence-news.com/2024/02/13/ai-21-labs-wordtune-chatgpt-plugin/", "summarize"],
["https://www.artificialintelligence-news.com/2024/02/12/google-responds-gemini-ai-historical-images/", "sentiment"],
["https://www.artificialintelligence-news.com/2024/02/09/anthropic-claude-3-models-preview/", "topics"]
]
gr.Examples(
examples=examples,
inputs=[url_input, mode],
outputs=output,
fn=analyze_content,
cache_examples=True
)
submit_btn.click(
fn=analyze_content,
inputs=[url_input, mode],
outputs=output
)
return iface
# Create and launch the interface
demo = create_interface()
demo.launch()