File size: 1,350 Bytes
37d1515
e8888cf
 
 
3a99d61
e8888cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

import gradio as gr
from smolagents import load_tool
import json

analyzer = load_tool("MHamdan/web-analyzer", trust_remote_code=True)

def create_interface():
    with gr.Blocks(title="Web Content Analyzer") as iface:
        gr.Markdown("# 🌐 Web Content Analyzer")
        gr.Markdown("""
        Get AI-powered analysis of any webpage:
        * πŸ“ Smart Summary
        * 😊 Sentiment Analysis
        * πŸ“Š Content Statistics
        """)
        
        url_input = gr.Textbox(
            label="Webpage URL",
            placeholder="https://example.com"
        )
        
        analyze_btn = gr.Button("Analyze")
        output = gr.JSON(label="Analysis Results")
        
        # Examples
        examples = [
            ["https://www.artificialintelligence-news.com/2024/02/14/openai-anthropic-google-white-house-red-teaming/"],
            ["https://www.artificialintelligence-news.com/2024/02/13/ai-21-labs-wordtune-chatgpt-plugin/"]
        ]
        
        gr.Examples(
            examples=examples,
            inputs=url_input,
            outputs=output,
            fn=analyzer,
            cache_examples=True
        )
        
        analyze_btn.click(
            fn=analyzer,
            inputs=url_input,
            outputs=output
        )
    
    return iface

demo = create_interface()
demo.launch()