Demo: Read a file.
()
| 38 | |
| 39 | |
| 40 | async def demo_read_tool(): |
| 41 | """Demo: Read a file.""" |
| 42 | print("\n" + "=" * 60) |
| 43 | print("Demo 2: ReadTool - Read file contents") |
| 44 | print("=" * 60) |
| 45 | |
| 46 | with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".txt") as f: |
| 47 | f.write("Line 1: Hello\nLine 2: World\nLine 3: Mini Agent") |
| 48 | temp_path = f.name |
| 49 | |
| 50 | try: |
| 51 | tool = ReadTool() |
| 52 | result = await tool.execute(path=temp_path) |
| 53 | |
| 54 | if result.success: |
| 55 | print(f"✅ File read successfully") |
| 56 | print(f"Content:\n{result.content}") |
| 57 | else: |
| 58 | print(f"❌ Failed: {result.error}") |
| 59 | finally: |
| 60 | Path(temp_path).unlink() |
| 61 | |
| 62 | |
| 63 | async def demo_edit_tool(): |