community: toolkits docstrings (#23286)

Added missed docstrings. Formatted docstrings to the consistent form.

---------

Co-authored-by: ccurme <chester.curme@gmail.com>
This commit is contained in:
Leonid Ganeline 2024-06-22 07:37:52 -07:00 committed by GitHub
parent 0cd3f93361
commit 987099cfcd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
38 changed files with 387 additions and 30 deletions

View File

@ -25,6 +25,12 @@ class AINetworkToolkit(BaseToolkit):
data associated with this service.
See https://python.langchain.com/docs/security for more information.
Parameters:
network: Optional. The network to connect to. Default is "testnet".
Options are "mainnet" or "testnet".
interface: Optional. The interface to use. If not provided, will
attempt to authenticate with the network. Default is None.
"""
network: Optional[Literal["mainnet", "testnet"]] = "testnet"
@ -32,6 +38,7 @@ class AINetworkToolkit(BaseToolkit):
@root_validator(pre=True)
def set_interface(cls, values: dict) -> dict:
"""Set the interface if not provided."""
if not values.get("interface"):
values["interface"] = authenticate(network=values.get("network", "testnet"))
return values
@ -39,7 +46,9 @@ class AINetworkToolkit(BaseToolkit):
class Config:
"""Pydantic config."""
# Allow extra fields. This is needed for the `interface` field.
validate_all = True
# Allow arbitrary types. This is needed for the `interface` field.
arbitrary_types_allowed = True
def get_tools(self) -> List[BaseTool]:

View File

@ -16,7 +16,12 @@ if TYPE_CHECKING:
class AmadeusToolkit(BaseToolkit):
"""Toolkit for interacting with Amadeus which offers APIs for travel."""
"""Toolkit for interacting with Amadeus which offers APIs for travel.
Parameters:
client: Optional. The Amadeus client. Default is None.
llm: Optional. The language model to use. Default is None.
"""
client: Client = Field(default_factory=authenticate)
llm: Optional[BaseLanguageModel] = Field(default=None)
@ -24,6 +29,7 @@ class AmadeusToolkit(BaseToolkit):
class Config:
"""Pydantic config."""
# Allow extra fields. This is needed for the `client` field.
arbitrary_types_allowed = True
def get_tools(self) -> List[BaseTool]:

View File

@ -1,4 +1,5 @@
"""Toolkits for agents."""
from langchain_core.tools import BaseToolkit
__all__ = ["BaseToolkit"]

View File

@ -1,4 +1,5 @@
"""Apache Cassandra Toolkit."""
from typing import List
from langchain_core.pydantic_v1 import Field
@ -14,13 +15,19 @@ from langchain_community.utilities.cassandra_database import CassandraDatabase
class CassandraDatabaseToolkit(BaseToolkit):
"""Toolkit for interacting with an Apache Cassandra database."""
"""Toolkit for interacting with an Apache Cassandra database.
Parameters:
db: CassandraDatabase. The Cassandra database to interact
with.
"""
db: CassandraDatabase = Field(exclude=True)
class Config:
"""Configuration for this pydantic object."""
# Allow arbitrary types. This is needed for the `db` field.
arbitrary_types_allowed = True
def get_tools(self) -> List[BaseTool]:

View File

@ -28,6 +28,9 @@ class ClickupToolkit(BaseToolkit):
data associated with this service.
See https://python.langchain.com/docs/security for more information.
Parameters:
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
"""
tools: List[BaseTool] = []
@ -36,6 +39,14 @@ class ClickupToolkit(BaseToolkit):
def from_clickup_api_wrapper(
cls, clickup_api_wrapper: ClickupAPIWrapper
) -> "ClickupToolkit":
"""Create a ClickupToolkit from a ClickupAPIWrapper.
Args:
clickup_api_wrapper: ClickupAPIWrapper. The Clickup API wrapper.
Returns:
ClickupToolkit. The Clickup toolkit.
"""
operations: List[Dict] = [
{
"mode": "get_task",

View File

@ -12,16 +12,20 @@ from langchain_community.tools.cogniswitch.tool import (
class CogniswitchToolkit(BaseToolkit):
"""
Toolkit for CogniSwitch.
"""Toolkit for CogniSwitch.
Use the toolkit to get all the tools present in the cogniswitch and
use them to interact with your knowledge
Use the toolkit to get all the tools present in the Cogniswitch and
use them to interact with your knowledge.
Parameters:
cs_token: str. The Cogniswitch token.
OAI_token: str. The OpenAI API token.
apiKey: str. The Cogniswitch OAuth token.
"""
cs_token: str # cogniswitch token
OAI_token: str # OpenAI API token
apiKey: str # Cogniswitch OAuth token
cs_token: str
OAI_token: str
apiKey: str
def get_tools(self) -> List[BaseTool]:
"""Get the tools in the toolkit."""

View File

@ -9,6 +9,9 @@ from langchain_community.tools.connery import ConneryService
class ConneryToolkit(BaseToolkit):
"""
Toolkit with a list of Connery Actions as tools.
Parameters:
tools (List[BaseTool]): The list of Connery Actions.
"""
tools: List[BaseTool]
@ -23,6 +26,7 @@ class ConneryToolkit(BaseToolkit):
def validate_attributes(cls, values: dict) -> dict:
"""
Validate the attributes of the ConneryToolkit class.
Parameters:
values (dict): The arguments to validate.
Returns:
@ -38,9 +42,10 @@ class ConneryToolkit(BaseToolkit):
def create_instance(cls, connery_service: ConneryService) -> "ConneryToolkit":
"""
Creates a Connery Toolkit using a Connery Service.
Parameters:
connery_service (ConneryService): The Connery Service
to to get the list of Connery Actions.
to to get the list of Connery Actions.
Returns:
ConneryToolkit: The Connery Toolkit.
"""

View File

@ -49,6 +49,13 @@ class FileManagementToolkit(BaseToolkit):
- Sandbox the agent by running it in a container.
See https://python.langchain.com/docs/security for more information.
Parameters:
root_dir: Optional. The root directory to perform file operations.
If not provided, file operations are performed relative to the current
working directory.
selected_tools: Optional. The tools to include in the toolkit. If not
provided, all tools are included.
"""
root_dir: Optional[str] = None

View File

@ -1,4 +1,5 @@
"""GitHub Toolkit."""
from typing import Dict, List
from langchain_core.pydantic_v1 import BaseModel, Field
@ -162,6 +163,9 @@ class GitHubToolkit(BaseToolkit):
and comments on GitHub.
See [Security](https://python.langchain.com/docs/security) for more information.
Parameters:
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
"""
tools: List[BaseTool] = []
@ -170,6 +174,14 @@ class GitHubToolkit(BaseToolkit):
def from_github_api_wrapper(
cls, github_api_wrapper: GitHubAPIWrapper
) -> "GitHubToolkit":
"""Create a GitHubToolkit from a GitHubAPIWrapper.
Args:
github_api_wrapper: GitHubAPIWrapper. The GitHub API wrapper.
Returns:
GitHubToolkit. The GitHub toolkit.
"""
operations: List[Dict] = [
{
"mode": "get_issues",

View File

@ -1,4 +1,5 @@
"""GitHub Toolkit."""
from typing import Dict, List
from langchain_core.tools import BaseToolkit
@ -29,6 +30,9 @@ class GitLabToolkit(BaseToolkit):
and comments on GitLab.
See https://python.langchain.com/docs/security for more information.
Parameters:
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
"""
tools: List[BaseTool] = []

View File

@ -38,6 +38,9 @@ class GmailToolkit(BaseToolkit):
associated account.
See https://python.langchain.com/docs/security for more information.
Parameters:
api_resource: Optional. The Google API resource. Default is None.
"""
api_resource: Resource = Field(default_factory=build_resource_service)

View File

@ -22,12 +22,24 @@ class JiraToolkit(BaseToolkit):
reading underlying data.
See https://python.langchain.com/docs/security for more information.
Parameters:
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
"""
tools: List[BaseTool] = []
@classmethod
def from_jira_api_wrapper(cls, jira_api_wrapper: JiraAPIWrapper) -> "JiraToolkit":
"""Create a JiraToolkit from a JiraAPIWrapper.
Args:
jira_api_wrapper: JiraAPIWrapper. The Jira API wrapper.
Returns:
JiraToolkit. The Jira toolkit.
"""
operations: List[Dict] = [
{
"mode": "jql",

View File

@ -1,4 +1,5 @@
"""Json agent."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List, Optional
@ -25,7 +26,23 @@ def create_json_agent(
agent_executor_kwargs: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> AgentExecutor:
"""Construct a json agent from an LLM and tools."""
"""Construct a json agent from an LLM and tools.
Args:
llm: The language model to use.
toolkit: The toolkit to use.
callback_manager: The callback manager to use. Default is None.
prefix: The prefix to use. Default is JSON_PREFIX.
suffix: The suffix to use. Default is JSON_SUFFIX.
format_instructions: The format instructions to use. Default is None.
input_variables: The input variables to use. Default is None.
verbose: Whether to print verbose output. Default is False.
agent_executor_kwargs: Optional additional arguments for the agent executor.
**kwargs: Additional arguments for the agent.
Returns:
The agent executor.
"""
from langchain.agents.agent import AgentExecutor
from langchain.agents.mrkl.base import ZeroShotAgent
from langchain.chains.llm import LLMChain

View File

@ -13,7 +13,11 @@ from langchain_community.tools.json.tool import (
class JsonToolkit(BaseToolkit):
"""Toolkit for interacting with a JSON spec."""
"""Toolkit for interacting with a JSON spec.
Parameters:
spec: The JSON spec.
"""
spec: JsonSpec

View File

@ -14,6 +14,7 @@ whether permissions of the given toolkit are appropriate for the application.
See [Security](https://python.langchain.com/docs/security) for more information.
"""
import warnings
from typing import Any, Dict, List, Optional, Callable, Tuple

View File

@ -1,4 +1,5 @@
"""MultiOn agent."""
from __future__ import annotations
from typing import List

View File

@ -14,7 +14,11 @@ from langchain_community.utilities.nasa import NasaAPIWrapper
class NasaToolkit(BaseToolkit):
"""Nasa Toolkit."""
"""Nasa Toolkit.
Parameters:
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
"""
tools: List[BaseTool] = []

View File

@ -20,7 +20,15 @@ class NLATool(Tool):
def from_open_api_endpoint_chain(
cls, chain: OpenAPIEndpointChain, api_title: str
) -> "NLATool":
"""Convert an endpoint chain to an API endpoint tool."""
"""Convert an endpoint chain to an API endpoint tool.
Args:
chain: The endpoint chain.
api_title: The title of the API.
Returns:
The API endpoint tool.
"""
expanded_name = (
f'{api_title.replace(" ", "_")}.{chain.api_operation.operation_id}'
)
@ -43,7 +51,22 @@ class NLATool(Tool):
return_intermediate_steps: bool = False,
**kwargs: Any,
) -> "NLATool":
"""Instantiate the tool from the specified path and method."""
"""Instantiate the tool from the specified path and method.
Args:
llm: The language model to use.
path: The path of the API.
method: The method of the API.
spec: The OpenAPI spec.
requests: Optional requests object. Default is None.
verbose: Whether to print verbose output. Default is False.
return_intermediate_steps: Whether to return intermediate steps.
Default is False.
**kwargs: Additional arguments.
Returns:
The tool.
"""
api_operation = APIOperation.from_openapi_spec(spec, path, method)
chain = OpenAPIEndpointChain.from_api_operation(
api_operation,

View File

@ -69,7 +69,18 @@ class NLAToolkit(BaseToolkit):
verbose: bool = False,
**kwargs: Any,
) -> NLAToolkit:
"""Instantiate the toolkit by creating tools for each operation."""
"""Instantiate the toolkit by creating tools for each operation.
Args:
llm: The language model to use.
spec: The OpenAPI spec.
requests: Optional requests object. Default is None.
verbose: Whether to print verbose output. Default is False.
**kwargs: Additional arguments.
Returns:
The toolkit.
"""
http_operation_tools = cls._get_http_operation_tools(
llm=llm, spec=spec, requests=requests, verbose=verbose, **kwargs
)
@ -84,7 +95,19 @@ class NLAToolkit(BaseToolkit):
verbose: bool = False,
**kwargs: Any,
) -> NLAToolkit:
"""Instantiate the toolkit from an OpenAPI Spec URL"""
"""Instantiate the toolkit from an OpenAPI Spec URL.
Args:
llm: The language model to use.
open_api_url: The URL of the OpenAPI spec.
requests: Optional requests object. Default is None.
verbose: Whether to print verbose output. Default is False.
**kwargs: Additional arguments.
Returns:
The toolkit.
"""
spec = OpenAPISpec.from_url(open_api_url)
return cls.from_llm_and_spec(
llm=llm, spec=spec, requests=requests, verbose=verbose, **kwargs

View File

@ -33,6 +33,9 @@ class O365Toolkit(BaseToolkit):
are appropriate for your use case.
See https://python.langchain.com/docs/security for more information.
Parameters:
account: Optional. The Office 365 account. Default is None.
"""
account: Account = Field(default_factory=authenticate)

View File

@ -1,4 +1,5 @@
"""OpenAPI spec agent."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List, Optional
@ -45,6 +46,28 @@ def create_openapi_agent(
what network access it has.
See https://python.langchain.com/docs/security for more information.
Args:
llm: The language model to use.
toolkit: The OpenAPI toolkit.
callback_manager: Optional. The callback manager. Default is None.
prefix: Optional. The prefix for the prompt. Default is OPENAPI_PREFIX.
suffix: Optional. The suffix for the prompt. Default is OPENAPI_SUFFIX.
format_instructions: Optional. The format instructions for the prompt.
Default is None.
input_variables: Optional. The input variables for the prompt. Default is None.
max_iterations: Optional. The maximum number of iterations. Default is 15.
max_execution_time: Optional. The maximum execution time. Default is None.
early_stopping_method: Optional. The early stopping method. Default is "force".
verbose: Optional. Whether to print verbose output. Default is False.
return_intermediate_steps: Optional. Whether to return intermediate steps.
Default is False.
agent_executor_kwargs: Optional. Additional keyword arguments
for the agent executor.
**kwargs: Additional arguments.
Returns:
The agent executor.
"""
from langchain.agents.agent import AgentExecutor
from langchain.agents.mrkl.base import ZeroShotAgent

View File

@ -403,6 +403,24 @@ def create_openapi_agent(
and avoid accepting inputs from untrusted sources without proper sandboxing.
Please see: https://python.langchain.com/docs/security
for further security information.
Args:
api_spec: The OpenAPI spec.
requests_wrapper: The requests wrapper.
llm: The language model.
shared_memory: Optional. The shared memory. Default is None.
callback_manager: Optional. The callback manager. Default is None.
verbose: Optional. Whether to print verbose output. Default is True.
agent_executor_kwargs: Optional. Additional keyword arguments
for the agent executor.
allow_dangerous_requests: Optional. Whether to allow dangerous requests.
Default is False.
allowed_operations: Optional. The allowed operations.
Default is ("GET", "POST").
**kwargs: Additional arguments.
Returns:
The agent executor.
"""
from langchain.agents.agent import AgentExecutor
from langchain.agents.mrkl.base import ZeroShotAgent

View File

@ -12,7 +12,7 @@ class ReducedOpenAPISpec:
This is a quick and dirty representation for OpenAPI specs.
Attributes:
Parameters:
servers: The servers in the spec.
description: The description of the spec.
endpoints: The endpoints in the spec.
@ -30,6 +30,13 @@ def reduce_openapi_spec(spec: dict, dereference: bool = True) -> ReducedOpenAPIS
I want smaller results from retrieval.
I was hoping https://openapi.tools/ would have some useful bits
to this end, but doesn't seem so.
Args:
spec: The OpenAPI spec.
dereference: Whether to dereference the spec. Default is True.
Returns:
ReducedOpenAPISpec: The reduced OpenAPI spec.
"""
# 1. Consider only get, post, patch, put, delete endpoints.
endpoints = [

View File

@ -1,4 +1,5 @@
"""Requests toolkit."""
from __future__ import annotations
from typing import Any, List
@ -40,6 +41,7 @@ class RequestsToolkit(BaseToolkit):
"""
requests_wrapper: TextRequestsWrapper
"""The requests wrapper."""
allow_dangerous_requests: bool = False
"""Allow dangerous requests. See documentation for details."""
@ -81,7 +83,9 @@ class OpenAPIToolkit(BaseToolkit):
"""
json_agent: Any
"""The JSON agent."""
requests_wrapper: TextRequestsWrapper
"""The requests wrapper."""
allow_dangerous_requests: bool = False
"""Allow dangerous requests. See documentation for details."""

View File

@ -1,4 +1,5 @@
"""Playwright browser toolkit."""
from langchain_community.agent_toolkits.playwright.toolkit import (
PlayWrightBrowserToolkit,
)

View File

@ -1,4 +1,5 @@
"""Playwright web browser toolkit."""
from __future__ import annotations
from typing import TYPE_CHECKING, List, Optional, Type, cast
@ -58,6 +59,10 @@ class PlayWrightBrowserToolkit(BaseToolkit):
tools.
See https://python.langchain.com/docs/security for more information.
Parameters:
sync_browser: Optional. The sync browser. Default is None.
async_browser: Optional. The async browser. Default is None.
"""
sync_browser: Optional["SyncBrowser"] = None
@ -103,7 +108,15 @@ class PlayWrightBrowserToolkit(BaseToolkit):
sync_browser: Optional[SyncBrowser] = None,
async_browser: Optional[AsyncBrowser] = None,
) -> PlayWrightBrowserToolkit:
"""Instantiate the toolkit."""
"""Instantiate the toolkit.
Args:
sync_browser: Optional. The sync browser. Default is None.
async_browser: Optional. The async browser. Default is None.
Returns:
The toolkit.
"""
# This is to raise a better error than the forward ref ones Pydantic would have
lazy_import_playwright_browsers()
return cls(sync_browser=sync_browser, async_browser=async_browser)

View File

@ -13,7 +13,11 @@ from langchain_community.utilities.polygon import PolygonAPIWrapper
class PolygonToolkit(BaseToolkit):
"""Polygon Toolkit."""
"""Polygon Toolkit.
Parameters:
tools: List[BaseTool]. The tools in the toolkit.
"""
tools: List[BaseTool] = []
@ -21,6 +25,14 @@ class PolygonToolkit(BaseToolkit):
def from_polygon_api_wrapper(
cls, polygon_api_wrapper: PolygonAPIWrapper
) -> "PolygonToolkit":
"""Create a Polygon Toolkit from a Polygon API Wrapper.
Args:
polygon_api_wrapper: PolygonAPIWrapper. The Polygon API Wrapper.
Returns:
PolygonToolkit. The Polygon Toolkit.
"""
tools = [
PolygonAggregates(
api_wrapper=polygon_api_wrapper,

View File

@ -1,4 +1,5 @@
"""Power BI agent."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List, Optional
@ -32,7 +33,27 @@ def create_pbi_agent(
agent_executor_kwargs: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> AgentExecutor:
"""Construct a Power BI agent from an LLM and tools."""
"""Construct a Power BI agent from an LLM and tools.
Args:
llm: The language model to use.
toolkit: Optional. The Power BI toolkit. Default is None.
powerbi: Optional. The Power BI dataset. Default is None.
callback_manager: Optional. The callback manager. Default is None.
prefix: Optional. The prefix for the prompt. Default is POWERBI_PREFIX.
suffix: Optional. The suffix for the prompt. Default is POWERBI_SUFFIX.
format_instructions: Optional. The format instructions for the prompt.
Default is None.
examples: Optional. The examples for the prompt. Default is None.
input_variables: Optional. The input variables for the prompt. Default is None.
top_k: Optional. The top k for the prompt. Default is 10.
verbose: Optional. Whether to print verbose output. Default is False.
agent_executor_kwargs: Optional. The agent executor kwargs. Default is None.
kwargs: Any. Additional keyword arguments.
Returns:
The agent executor.
"""
from langchain.agents import AgentExecutor
from langchain.agents.mrkl.base import ZeroShotAgent
from langchain.chains.llm import LLMChain

View File

@ -1,4 +1,5 @@
"""Power BI agent."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List, Optional
@ -38,6 +39,25 @@ def create_pbi_chat_agent(
"""Construct a Power BI agent from a Chat LLM and tools.
If you supply only a toolkit and no Power BI dataset, the same LLM is used for both.
Args:
llm: The language model to use.
toolkit: Optional. The Power BI toolkit. Default is None.
powerbi: Optional. The Power BI dataset. Default is None.
callback_manager: Optional. The callback manager. Default is None.
output_parser: Optional. The output parser. Default is None.
prefix: Optional. The prefix for the prompt. Default is POWERBI_CHAT_PREFIX.
suffix: Optional. The suffix for the prompt. Default is POWERBI_CHAT_SUFFIX.
examples: Optional. The examples for the prompt. Default is None.
input_variables: Optional. The input variables for the prompt. Default is None.
memory: Optional. The memory. Default is None.
top_k: Optional. The top k for the prompt. Default is 10.
verbose: Optional. Whether to print verbose output. Default is False.
agent_executor_kwargs: Optional. The agent executor kwargs. Default is None.
kwargs: Any. Additional keyword arguments.
Returns:
The agent executor.
"""
from langchain.agents import AgentExecutor
from langchain.agents.conversational_chat.base import ConversationalChatAgent

View File

@ -1,7 +1,6 @@
# flake8: noqa
"""Prompts for PowerBI agent."""
POWERBI_PREFIX = """You are an agent designed to help users interact with a PowerBI Dataset.
Agent has access to a tool that can write a query based on the question and then run those against PowerBI, Microsofts business intelligence tool. The questions from the users should be interpreted as related to the dataset that is available and not general questions about the world. If the question does not seem related to the dataset, return "This does not appear to be part of this dataset." as the answer.

View File

@ -1,4 +1,5 @@
"""Toolkit for interacting with a Power BI dataset."""
from __future__ import annotations
from typing import TYPE_CHECKING, List, Optional, Union
@ -43,6 +44,15 @@ class PowerBIToolkit(BaseToolkit):
code are appropriately scoped to the application.
See https://python.langchain.com/docs/security for more information.
Parameters:
powerbi: The Power BI dataset.
llm: The language model to use.
examples: Optional. The examples for the prompt. Default is None.
max_iterations: Optional. The maximum iterations to run. Default is 5.
callback_manager: Optional. The callback manager. Default is None.
output_token_limit: Optional. The output token limit. Default is None.
tiktoken_model_name: Optional. The TikToken model name. Default is None.
"""
powerbi: PowerBIDataset = Field(exclude=True)

View File

@ -17,7 +17,11 @@ if TYPE_CHECKING:
class SlackToolkit(BaseToolkit):
"""Toolkit for interacting with Slack."""
"""Toolkit for interacting with Slack.
Parameters:
client: The Slack client.
"""
client: WebClient = Field(default_factory=login)

View File

@ -1,4 +1,5 @@
"""Spark SQL agent."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List, Optional
@ -30,7 +31,29 @@ def create_spark_sql_agent(
agent_executor_kwargs: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> AgentExecutor:
"""Construct a Spark SQL agent from an LLM and tools."""
"""Construct a Spark SQL agent from an LLM and tools.
Args:
llm: The language model to use.
toolkit: The Spark SQL toolkit.
callback_manager: Optional. The callback manager. Default is None.
callbacks: Optional. The callbacks. Default is None.
prefix: Optional. The prefix for the prompt. Default is SQL_PREFIX.
suffix: Optional. The suffix for the prompt. Default is SQL_SUFFIX.
format_instructions: Optional. The format instructions for the prompt.
Default is None.
input_variables: Optional. The input variables for the prompt. Default is None.
top_k: Optional. The top k for the prompt. Default is 10.
max_iterations: Optional. The maximum iterations to run. Default is 15.
max_execution_time: Optional. The maximum execution time. Default is None.
early_stopping_method: Optional. The early stopping method. Default is "force".
verbose: Optional. Whether to print verbose output. Default is False.
agent_executor_kwargs: Optional. The agent executor kwargs. Default is None.
kwargs: Any. Additional keyword arguments.
Returns:
The agent executor.
"""
from langchain.agents.agent import AgentExecutor
from langchain.agents.mrkl.base import ZeroShotAgent
from langchain.chains.llm import LLMChain

View File

@ -1,4 +1,5 @@
"""Toolkit for interacting with Spark SQL."""
from typing import List
from langchain_core.language_models import BaseLanguageModel
@ -16,7 +17,12 @@ from langchain_community.utilities.spark_sql import SparkSQL
class SparkSQLToolkit(BaseToolkit):
"""Toolkit for interacting with Spark SQL."""
"""Toolkit for interacting with Spark SQL.
Parameters:
db: SparkSQL. The Spark SQL database.
llm: BaseLanguageModel. The language model.
"""
db: SparkSQL = Field(exclude=True)
llm: BaseLanguageModel = Field(exclude=True)

View File

@ -1,4 +1,5 @@
"""SQL agent."""
from __future__ import annotations
from typing import (

View File

@ -1,4 +1,5 @@
"""Toolkit for interacting with an SQL database."""
from typing import List
from langchain_core.language_models import BaseLanguageModel
@ -16,7 +17,12 @@ from langchain_community.utilities.sql_database import SQLDatabase
class SQLDatabaseToolkit(BaseToolkit):
"""Toolkit for interacting with SQL databases."""
"""Toolkit for interacting with SQL databases.
Parameters:
db: SQLDatabase. The SQL database.
llm: BaseLanguageModel. The language model.
"""
db: SQLDatabase = Field(exclude=True)
llm: BaseLanguageModel = Field(exclude=True)

View File

@ -1,4 +1,5 @@
"""Steam Toolkit."""
from typing import List
from langchain_core.tools import BaseToolkit
@ -13,7 +14,11 @@ from langchain_community.utilities.steam import SteamWebAPIWrapper
class SteamToolkit(BaseToolkit):
"""Steam Toolkit."""
"""Steam Toolkit.
Parameters:
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
"""
tools: List[BaseTool] = []
@ -21,6 +26,14 @@ class SteamToolkit(BaseToolkit):
def from_steam_api_wrapper(
cls, steam_api_wrapper: SteamWebAPIWrapper
) -> "SteamToolkit":
"""Create a Steam Toolkit from a Steam API Wrapper.
Args:
steam_api_wrapper: SteamWebAPIWrapper. The Steam API Wrapper.
Returns:
SteamToolkit. The Steam Toolkit.
"""
operations: List[dict] = [
{
"mode": "get_games_details",

View File

@ -1,4 +1,5 @@
"""[DEPRECATED] Zapier Toolkit."""
from typing import List
from langchain_core._api import warn_deprecated
@ -10,7 +11,11 @@ from langchain_community.utilities.zapier import ZapierNLAWrapper
class ZapierToolkit(BaseToolkit):
"""Zapier Toolkit."""
"""Zapier Toolkit.
Parameters:
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
"""
tools: List[BaseTool] = []
@ -18,7 +23,14 @@ class ZapierToolkit(BaseToolkit):
def from_zapier_nla_wrapper(
cls, zapier_nla_wrapper: ZapierNLAWrapper
) -> "ZapierToolkit":
"""Create a toolkit from a ZapierNLAWrapper."""
"""Create a toolkit from a ZapierNLAWrapper.
Args:
zapier_nla_wrapper: ZapierNLAWrapper. The Zapier NLA wrapper.
Returns:
ZapierToolkit. The Zapier toolkit.
"""
actions = zapier_nla_wrapper.list()
tools = [
ZapierNLARunAction(
@ -35,7 +47,14 @@ class ZapierToolkit(BaseToolkit):
async def async_from_zapier_nla_wrapper(
cls, zapier_nla_wrapper: ZapierNLAWrapper
) -> "ZapierToolkit":
"""Create a toolkit from a ZapierNLAWrapper."""
"""Async create a toolkit from a ZapierNLAWrapper.
Args:
zapier_nla_wrapper: ZapierNLAWrapper. The Zapier NLA wrapper.
Returns:
ZapierToolkit. The Zapier toolkit.
"""
actions = await zapier_nla_wrapper.alist()
tools = [
ZapierNLARunAction(