File size: 972 Bytes
62304db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from smolagents import Tool
from typing import Any, Optional

class SimpleTool(Tool):
    name = "save_notes_to_file"
    description = "Save generated notes to a file."
    inputs = {"unit_number":{"type":"integer","description":"The unit number"},"unit_name":{"type":"string","description":"Name of the unit"},"content":{"type":"string","description":"Content to save"}}
    output_type = "string"

    def forward(self, unit_number: int,
        unit_name: str,
        content: str) -> str:
        """
        Save generated notes to a file.

        Args:
            unit_number: The unit number
            unit_name: Name of the unit
            content: Content to save

        Returns:
            Confirmation message
        """
        filename = f"unit_{unit_number}_{unit_name.replace(' ', '_').lower()}.md"
        with open(filename, "w") as f:
            f.write(content)
        return f"Notes for Unit {unit_number}: {unit_name} saved to {filename}"