wt002 commited on
Commit
65303ab
·
verified ·
1 Parent(s): 2c66cb4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -19,6 +19,29 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
19
  #Load environment variables
20
  load_dotenv()
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  class StringReverseTool(Tool):
23
  name = "reverse_message"
24
  description = "When you received a strange text, try to reverse it and perform action described in reversed message."
@@ -110,6 +133,8 @@ def parse_excel_to_json(task_id: str) -> dict:
110
  "status": f"Error in parsing Excel file: {str(e)}"
111
  }
112
 
 
 
113
  class VideoTranscriptionTool(Tool):
114
  """Fetch transcripts from YouTube videos"""
115
  name = "transcript_video"
 
19
  #Load environment variables
20
  load_dotenv()
21
 
22
+
23
+ from smolagents import Tool
24
+ import wikipediaapi
25
+
26
+ class WikipediaSearchTool(Tool):
27
+ name = "wikipedia_search"
28
+ description = "Fetches a summary of a Wikipedia page based on a given search query (only one word or group of words)."
29
+ inputs = {
30
+ "query": {"type": "string", "description": "The search term for the Wikipedia page (only one word or group of words)."}
31
+ }
32
+ output_type = "string"
33
+
34
+ def __init__(self, lang="en"):
35
+ super().__init__()
36
+ self.wiki = wikipediaapi.Wikipedia(language=lang, user_agent="MinimalAgent/1.0")
37
+
38
+ def forward(self, query: str):
39
+ page = self.wiki.page(query)
40
+ if not page.exists():
41
+ return "No Wikipedia page found."
42
+ return page.summary[:1000]
43
+
44
+
45
  class StringReverseTool(Tool):
46
  name = "reverse_message"
47
  description = "When you received a strange text, try to reverse it and perform action described in reversed message."
 
133
  "status": f"Error in parsing Excel file: {str(e)}"
134
  }
135
 
136
+
137
+
138
  class VideoTranscriptionTool(Tool):
139
  """Fetch transcripts from YouTube videos"""
140
  name = "transcript_video"