GitExplorer / smolagent_main.py
mmartin's picture
add examples
56e32a0
raw
history blame contribute delete
872 Bytes
import os
from smolagents import CodeAgent, tool, HfApiModel
# Tool to suggest a menu based on the occasion
@tool
def git_exploreer(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")
# Alfred, the butler, preparing the menu for the party
agent = CodeAgent(tools=[git_exploreer], model=HfApiModel())
# Preparing the menu for the party
# agent.run("What is the git command to list all branches?")
# Change to your username and repo name
agent.push_to_hub('mmartin/GitExplorer',
token=os.environ.get('HF_TOKEN_WRITE', None))