MHamdan commited on
Commit
7eef865
·
verified ·
1 Parent(s): 3058953

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +38 -4
app.py CHANGED
@@ -1,6 +1,40 @@
1
- from smolagents import launch_gradio_demo
2
- from tool import SimpleTool
3
 
4
- tool = SimpleTool()
 
5
 
6
- launch_gradio_demo(tool)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ import gradio as gr
3
+ from smolagents import load_tool
4
 
5
+ web_extractor = load_tool("MHamdan/web-content-extractor", trust_remote_code=True)
6
+
7
+ def create_interface():
8
+ with gr.Blocks(title="Web Content Extractor") as iface:
9
+ gr.Markdown("# Web Content Extractor")
10
+ gr.Markdown("Extract and analyze content from any webpage.")
11
+
12
+ with gr.Row():
13
+ with gr.Column():
14
+ url_input = gr.Textbox(
15
+ label="Webpage URL",
16
+ placeholder="https://example.com"
17
+ )
18
+ content_type = gr.Dropdown(
19
+ choices=["all", "text", "links", "headers"],
20
+ label="Content Type",
21
+ value="all"
22
+ )
23
+ submit_btn = gr.Button("Extract Content")
24
+
25
+ with gr.Column():
26
+ output = gr.Textbox(
27
+ label="Extracted Content",
28
+ lines=10
29
+ )
30
+
31
+ submit_btn.click(
32
+ fn=web_extractor,
33
+ inputs=[url_input, content_type],
34
+ outputs=output
35
+ )
36
+
37
+ return iface
38
+
39
+ demo = create_interface()
40
+ demo.launch()