Spaces:
Runtime error
Runtime error
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() | |