Spaces:
Sleeping
Sleeping
| from smolagents import Tool | |
| import wikipediaapi | |
| class WikipediaTool(Tool): | |
| name = "wikipedia_lookup" | |
| description = "Fetches English Wikipedia summary for a given topic." | |
| inputs = { | |
| "query": {"type": "string", "description": "The Wikipedia page title to retrieve."} | |
| } | |
| output_type = "string" | |
| def forward(self, query: str) -> str: | |
| wiki = wikipediaapi.Wikipedia('en') | |
| page = wiki.page(query) | |
| if not page.exists(): | |
| return f"Wikipedia page '{query}' does not exist." | |
| return page.summary[:1000] | |
| class TextTransformerTool(Tool): | |
| name = "text_transformer" | |
| description = "Reverses the input text." | |
| inputs = { | |
| "text": {"type": "string", "description": "Text to reverse."} | |
| } | |
| output_type = "string" | |
| def forward(self, text: str) -> str: | |
| return text[::-1] |