GitExplorer / tools /git_exploreer.py
mmartin's picture
Upload agent
0565d7d verified
raw
history blame contribute delete
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")