ab-huggingface commited on
Commit
2c7246c
·
verified ·
1 Parent(s): d1eed8a

Update app.py

Browse files

Adding a new tool to check / verify news

Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -33,6 +33,24 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  final_answer = FinalAnswerTool()
38
 
@@ -55,7 +73,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[image_generation_tool], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+ @tool
37
+ def classify_news_article(article_text: str) -> str:
38
+ """
39
+ Classifies a news article as 'Real' or 'Fake' based on its content.
40
+
41
+ Args:
42
+ article_text (str): The content of the news article to be classified.
43
+
44
+ Returns:
45
+ str: 'Real' if the article is classified as real news, 'Fake' otherwise.
46
+ """
47
+ # Perform classification
48
+ model_name = "Pulk17/Fake-News-Detection"
49
+ classifier = pipeline("text-classification", model=model_name)
50
+ result = classifier(article_text[:500])[0] # Truncate to 500 words as per model's requirement
51
+ label = result['label'] # 'LABEL_0' for fake news, 'LABEL_1' for real news
52
+ return "Real" if label == 'LABEL_1' else "Fake"
53
+
54
 
55
  final_answer = FinalAnswerTool()
56
 
 
73
 
74
  agent = CodeAgent(
75
  model=model,
76
+ tools=[image_generation_tool,classify_news_article], ## add your tools here (don't remove final answer)
77
  max_steps=6,
78
  verbosity_level=1,
79
  grammar=None,