-
Notifications
You must be signed in to change notification settings - Fork 1.9k
docstring args for ToolCallingAgent, CodeAgent and ManagedAgent #335
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
albertvillanova
merged 4 commits into
huggingface:main
from
touseefahmed96:doc-string-agents
Jan 24, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ded88d7
docstring args for ToolCallingAgent, CodeAgent and ManagedAgent
touseefahmed96 67f04a6
Fix ToolCallingAgent and CodeAgent docstring
touseefahmed96 51879a2
Merge remote-tracking branch 'upstream/main' into doc-string-agents
albertvillanova 54f2ad5
Minor fix
albertvillanova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -670,6 +670,14 @@ def planning_step(self, task, is_first_step: bool, step: int) -> None: | |
class ToolCallingAgent(MultiStepAgent): | ||
""" | ||
This agent uses JSON-like tool calls, using method `model.get_tool_call` to leverage the LLM engine's tool calling capabilities. | ||
|
||
Args: | ||
tools (`list[Tool]`): [`Tool`]s that the agent can use. | ||
model (`Callable[[list[dict[str, str]]], ChatMessage]`): Model that will generate the agent's actions. | ||
system_prompt (`str`, *optional*): System prompt that will be used to generate the agent's actions. | ||
planning_interval (`int`, *optional*): Interval at which the agent will run a planning step. | ||
**kwargs: Additional keyword arguments. | ||
|
||
""" | ||
|
||
def __init__( | ||
|
@@ -776,6 +784,18 @@ def step(self, log_entry: ActionStep) -> Union[None, Any]: | |
class CodeAgent(MultiStepAgent): | ||
""" | ||
In this agent, the tool calls will be formulated by the LLM in code format, then parsed and executed. | ||
|
||
Args: | ||
tools (`list[Tool]`): [`Tool`]s that the agent can use. | ||
model (`Callable[[list[dict[str, str]]], ChatMessage]`): Model that will generate the agent's actions. | ||
system_prompt (`str`, *optional*): System prompt that will be used to generate the agent's actions. | ||
grammar (`dict[str, str]`, *optional*): Grammar used to parse the LLM output. | ||
additional_authorized_imports (`list[str]`, *optional*): Additional authorized imports for the agent. | ||
planning_interval (`int`, *optional*): Interval at which the agent will run a planning step. | ||
use_e2b_executor (`bool`, default `False`): Whether to use the E2B executor for remote code execution. | ||
max_print_outputs_length (`int`, *optional*): Maximum length of the print outputs. | ||
**kwargs: Additional keyword arguments. | ||
|
||
""" | ||
|
||
def __init__( | ||
|
@@ -834,9 +854,11 @@ def initialize_system_prompt(self): | |
super().initialize_system_prompt() | ||
self.system_prompt = self.system_prompt.replace( | ||
"{{authorized_imports}}", | ||
"You can import from any package you want." | ||
if "*" in self.authorized_imports | ||
else str(self.authorized_imports), | ||
( | ||
"You can import from any package you want." | ||
if "*" in self.authorized_imports | ||
else str(self.authorized_imports) | ||
), | ||
) | ||
return self.system_prompt | ||
|
||
|
@@ -949,6 +971,19 @@ def step(self, log_entry: ActionStep) -> Union[None, Any]: | |
|
||
|
||
class ManagedAgent: | ||
""" | ||
ManagedAgent class that manages an agent and provides additional prompting and run summaries. | ||
|
||
Args: | ||
agent (`object`): The agent to be managed. | ||
name (`str`): The name of the managed agent. | ||
description (`str`): A description of the managed agent. | ||
additional_prompting (`Optional[str]`, *optional*): Additional prompting for the managed agent. Defaults to None. | ||
provide_run_summary (`bool`, *optional*): Whether to provide a run summary after the agent completes its task. Defaults to False. | ||
managed_agent_prompt (`Optional[str]`, *optional*): Custom prompt for the managed agent. Defaults to None. | ||
Comment on lines
+978
to
+983
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's align the definitions with the ones above: better not start the description with "the" or "a". |
||
|
||
""" | ||
|
||
def __init__( | ||
self, | ||
agent, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant
Optional[]
and*optional*
. Better removing the first one.