Spaces:
Runtime error
Runtime error
| from smolagents import Tool | |
| from typing import Any, Optional | |
| class SimpleTool(Tool): | |
| name = "format_blog_post" | |
| description = "Format the blog post into a structured format." | |
| inputs = {'title': {'type': 'string', 'description': 'Title of the blog post.'}, 'content': {'type': 'string', 'description': 'Content of the blog post.'}, 'url': {'type': 'string', 'description': 'URL of the blog post.'}} | |
| output_type = "string" | |
| def forward(self, title: str, content: str, url: str) -> str: | |
| """ | |
| Format the blog post into a structured format. | |
| Args: | |
| title (str): Title of the blog post. | |
| content (str): Content of the blog post. | |
| url (str): URL of the blog post. | |
| Returns: | |
| str: Formatted blog post. | |
| """ | |
| from string import Template | |
| template = Template(""" | |
| # $title | |
| ## Summary | |
| $content | |
| ## URL | |
| $url | |
| """) | |
| return template.substitute(title=title, content=content, url=url) |