Demo: Write a new file.
()
| 17 | |
| 18 | |
| 19 | async def demo_write_tool(): |
| 20 | """Demo: Write a new file.""" |
| 21 | print("\n" + "=" * 60) |
| 22 | print("Demo 1: WriteTool - Create a new file") |
| 23 | print("=" * 60) |
| 24 | |
| 25 | with tempfile.TemporaryDirectory() as tmpdir: |
| 26 | file_path = Path(tmpdir) / "hello.txt" |
| 27 | |
| 28 | tool = WriteTool() |
| 29 | result = await tool.execute( |
| 30 | path=str(file_path), content="Hello, Mini Agent!\nThis is a test file." |
| 31 | ) |
| 32 | |
| 33 | if result.success: |
| 34 | print(f"✅ File created: {file_path}") |
| 35 | print(f"Content:\n{file_path.read_text()}") |
| 36 | else: |
| 37 | print(f"❌ Failed: {result.error}") |
| 38 | |
| 39 | |
| 40 | async def demo_read_tool(): |