community: docstrings toolkits (#23616)

Added missed docstrings. Formatted docstrings to the consistent form.
This commit is contained in:
Leonid Ganeline 2024-06-28 05:40:52 -07:00 committed by GitHub
parent 19eb82e68b
commit e4caa41aa9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 45 additions and 7 deletions

View File

@ -38,7 +38,17 @@ class AINetworkToolkit(BaseToolkit):
@root_validator(pre=True)
def set_interface(cls, values: dict) -> dict:
"""Set the interface if not provided."""
"""Set the interface if not provided.
If the interface is not provided, attempt to authenticate with the
network using the network value provided.
Args:
values: The values to validate.
Returns:
The validated values.
"""
if not values.get("interface"):
values["interface"] = authenticate(network=values.get("network", "testnet"))
return values

View File

@ -27,10 +27,13 @@ class ConneryToolkit(BaseToolkit):
"""
Validate the attributes of the ConneryToolkit class.
Parameters:
Args:
values (dict): The arguments to validate.
Returns:
dict: The validated arguments.
Raises:
ValueError: If the 'tools' attribute is not set
"""
if not values.get("tools"):
@ -45,7 +48,7 @@ class ConneryToolkit(BaseToolkit):
Parameters:
connery_service (ConneryService): The Connery Service
to to get the list of Connery Actions.
to get the list of Connery Actions.
Returns:
ConneryToolkit: The Connery Toolkit.
"""

View File

@ -41,6 +41,15 @@ class GitLabToolkit(BaseToolkit):
def from_gitlab_api_wrapper(
cls, gitlab_api_wrapper: GitLabAPIWrapper
) -> "GitLabToolkit":
"""Create a GitLabToolkit from a GitLabAPIWrapper.
Args:
gitlab_api_wrapper: GitLabAPIWrapper. The GitLab API wrapper.
Returns:
GitLabToolkit. The GitLab toolkit.
"""
operations: List[Dict] = [
{
"mode": "get_issues",

View File

@ -587,13 +587,17 @@ def load_huggingface_tool(
Args:
task_or_repo_id: Task or model repo id.
model_repo_id: Optional model repo id.
token: Optional token.
model_repo_id: Optional model repo id. Defaults to None.
token: Optional token. Defaults to None.
remote: Optional remote. Defaults to False.
**kwargs:
**kwargs: Additional keyword arguments.
Returns:
A tool.
Raises:
ImportError: If the required libraries are not installed.
NotImplementedError: If multimodal outputs or inputs are not supported.
"""
try:
from transformers import load_tool
@ -649,7 +653,8 @@ def load_tools(
Args:
tool_names: name of tools to load.
llm: An optional language model, may be needed to initialize certain tools.
llm: An optional language model may be needed to initialize certain tools.
Defaults to None.
callbacks: Optional callback manager or list of callback handlers.
If not provided, default global callback manager will be used.
allow_dangerous_tools: Optional flag to allow dangerous tools.
@ -661,9 +666,17 @@ def load_tools(
Please note that this list may not be fully exhaustive.
It is your responsibility to understand which tools
you're using and the risks associated with them.
Defaults to False.
**kwargs: Additional keyword arguments.
Returns:
List of tools.
Raises:
ValueError: If the tool name is unknown.
ValueError: If the tool requires an LLM to be provided.
ValueError: If the tool requires some parameters that were not provided.
ValueError: If the tool is a dangerous tool and allow_dangerous_tools is False.
"""
tools = []
callbacks = _handle_callbacks(

View File

@ -288,6 +288,9 @@ class OpenAIAssistantV2Runnable(OpenAIAssistantRunnable):
Union[List[OpenAIAssistantAction], OpenAIAssistantFinish]. Otherwise,
will return OpenAI types
Union[List[ThreadMessage], List[RequiredActionFunctionToolCall]].
Raises:
BaseException: If an error occurs during the invocation.
"""
config = ensure_config(config)