Spaces:
Sleeping
Sleeping
Updated Fake News Detective with Gradio and SmolAgents
Browse files
app.py
CHANGED
@@ -1,7 +1,25 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|