Ubik80 commited on
Commit
9c881b4
·
1 Parent(s): b50ad18

Updated Fake News Detective with Gradio and SmolAgents

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,7 +1,25 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
3
 
4
+ # Inizializza il modello e l'agente
5
+ search_tool = DuckDuckGoSearchTool()
6
+ model = HfApiModel()
7
+ agent = CodeAgent(model=model, tools=[search_tool])
8
 
9
+ # Funzione per analizzare le notizie
10
+ def detect_fake_news(news_text):
11
+ response = agent.run(f"Check if this news is true or fake: {news_text}")
12
+ return response
13
+
14
+ # Configurazione di Gradio
15
+ interface = gr.Interface(
16
+ fn=detect_fake_news,
17
+ inputs="text",
18
+ outputs="text",
19
+ title="🕵️ Fake News Detective",
20
+ description="Paste a news article or statement and get a credibility analysis."
21
+ )
22
+
23
+ # Avvio dell'app
24
+ if __name__ == "__main__":
25
+ interface.launch()