MHamdan commited on
Commit
c40e4ff
·
verified ·
1 Parent(s): 733edf6

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -1,14 +1,13 @@
1
 
2
  import gradio as gr
3
  from smolagents import load_tool
4
- import torch # Add explicit torch import
5
-
6
- # Ensure CUDA is available
7
- device = "cuda" if torch.cuda.is_available() else "cpu"
8
 
9
  # Load the tool
10
  web_analyzer = load_tool("MHamdan/web-analyzer", trust_remote_code=True)
11
 
 
 
 
12
  def create_interface():
13
  with gr.Blocks(title="AI Web Analyzer") as iface:
14
  gr.Markdown("# 🤖 AI-Powered Web Content Analyzer")
@@ -39,7 +38,7 @@ def create_interface():
39
  lines=15
40
  )
41
 
42
- # Example data using artificial-intelligence-news.com
43
  examples = [
44
  ["https://www.artificialintelligence-news.com/2024/02/14/openai-anthropic-google-white-house-red-teaming/", "analyze"],
45
  ["https://www.artificialintelligence-news.com/2024/02/13/ai-21-labs-wordtune-chatgpt-plugin/", "summarize"],
@@ -51,12 +50,12 @@ def create_interface():
51
  examples=examples,
52
  inputs=[url_input, mode],
53
  outputs=output,
54
- label="Try these examples:",
55
  cache_examples=True
56
  )
57
 
58
  submit_btn.click(
59
- fn=web_analyzer,
60
  inputs=[url_input, mode],
61
  outputs=output
62
  )
 
1
 
2
  import gradio as gr
3
  from smolagents import load_tool
 
 
 
 
4
 
5
  # Load the tool
6
  web_analyzer = load_tool("MHamdan/web-analyzer", trust_remote_code=True)
7
 
8
+ def analyze_content(url, mode):
9
+ return web_analyzer(url, mode)
10
+
11
  def create_interface():
12
  with gr.Blocks(title="AI Web Analyzer") as iface:
13
  gr.Markdown("# 🤖 AI-Powered Web Content Analyzer")
 
38
  lines=15
39
  )
40
 
41
+ # Example data
42
  examples = [
43
  ["https://www.artificialintelligence-news.com/2024/02/14/openai-anthropic-google-white-house-red-teaming/", "analyze"],
44
  ["https://www.artificialintelligence-news.com/2024/02/13/ai-21-labs-wordtune-chatgpt-plugin/", "summarize"],
 
50
  examples=examples,
51
  inputs=[url_input, mode],
52
  outputs=output,
53
+ fn=analyze_content,
54
  cache_examples=True
55
  )
56
 
57
  submit_btn.click(
58
+ fn=analyze_content,
59
  inputs=[url_input, mode],
60
  outputs=output
61
  )