8000 Update type hints and docstrings of Agent/Tool .save with Path type by albertvillanova · Pull Request #1036 · huggingface/smolagents · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update type hints and docstrings of Agent/Tool .save with Path type #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/smolagents/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def __call__(self, task: str, **kwargs):
answer += "\n</summary_of_work>"
return answer

def save(self, output_dir: str, relative_path: Optional[str] = None):
def save(self, output_dir: str | Path, relative_path: Optional[str] = None):
"""
Saves the relevant code files for your agent. This will copy the code of your agent in `output_dir` as well as autogenerate:

Expand All @@ -652,7 +652,7 @@ def save(self, output_dir: str, relative_path: Optional[str] = None):
code)

Args:
output_dir (`str`): The folder in which you want to save your tool.
output_dir (`str` or `Path`): The folder in which you want to save your agent.
"""
make_init_file(output_dir)

Expand Down
4 changes: 2 additions & 2 deletions src/smolagents/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def replacement(match):

return {"name": self.name, "code": tool_code, "requirements": requirements}

def save(self, output_dir: str, tool_file_name: str = "tool", make_gradio_app: bool = True):
def save(self, output_dir: str | Path, tool_file_name: str = "tool", make_gradio_app: bool = True):
"""
Saves the relevant code files for your tool so it can be pushed to the Hub. This will copy the code of your
tool in `output_dir` as well as autogenerate:
Expand All @@ -275,7 +275,7 @@ def save(self, output_dir: str, tool_file_name: str = "tool", make_gradio_app: b
code)

Args:
output_dir (`str`): The folder in which you want to save your tool.
output_dir (`str` or `Path`): The folder in which you want to save your tool.
tool_file_name (`str`, *optional*): The file name in which you want to save your tool.
make_gradio_app (`bool`, *optional*, defaults to True): Whether to also export a `requirements.txt` file and Gradio UI.
"""
Expand Down
0