Spaces:
Runtime error
Runtime error
File size: 2,352 Bytes
37d1515 3a99d61 c40e4ff 3a99d61 c40e4ff 3a99d61 c40e4ff 3a99d61 c40e4ff 3a99d61 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
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()
|