File size: 1,038 Bytes
4ff5af2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)