Spaces:
Sleeping
Sleeping
Download tools/git_exploreer.py from mmartin/GitExplorer: direct link, hf CLI and curl.
- Browser
- Download file 743 Bytes
-
https://huggingface.co/spaces/mmartin/GitExplorer/resolve/main/tools/git_exploreer.py
- Command line
-
hf download hf://spaces/mmartin/GitExplorer/tools/git_exploreer.py
-
curl -L -o git_exploreer.py https://huggingface.co/spaces/mmartin/GitExplorer/resolve/main/tools/git_exploreer.py
743 Bytes
| from smolagents import Tool | |
| from typing import Any, Optional | |
| class SimpleTool(Tool): | |
| name = "git_exploreer" | |
| description = "Executes the git command and returns the output." | |
| inputs = {"git_command":{"type":"string","description":"The git command to execute"}} | |
| output_type = "string" | |
| def forward(self, git_command: str) -> str: | |
| """ | |
| Executes the git command and returns the output. | |
| Args: | |
| git_command (str): | |
| The git command to execute | |
| Returns: | |
| str: The output of the git command | |
| """ | |
| import subprocess | |
| process = subprocess.Popen(git_command.split(), stdout=subprocess.PIPE) | |
| return process.communicate()[0].decode("utf-8") |