Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/ainetwork/__init__.py +1 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/ainetwork/toolkit.py +70 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/amadeus/__init__.py +0 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/amadeus/toolkit.py +38 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/cassandra_database/__init__.py +1 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/cassandra_database/toolkit.py +37 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/clickup/__init__.py +0 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/clickup/toolkit.py +120 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/cogniswitch/__init__.py +1 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/cogniswitch/toolkit.py +45 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/connery/__init__.py +7 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/connery/toolkit.py +60 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/csv/__init__.py +26 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/file_management/__init__.py +7 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/file_management/toolkit.py +88 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/financial_datasets/__init__.py +1 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/financial_datasets/toolkit.py +44 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/github/__init__.py +1 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/github/toolkit.py +479 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/gitlab/__init__.py +1 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/gitlab/toolkit.py +170 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/gmail/__init__.py +1 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/gmail/toolkit.py +132 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/jira/__init__.py +1 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/jira/toolkit.py +83 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/json/__init__.py +1 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/json/base.py +76 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/json/prompt.py +25 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/json/toolkit.py +29 -0
- python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/multion/toolkit.py +35 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/__init__.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/aim_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/argilla_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/arize_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/arthur_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/bedrock_anthropic_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/clearml_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/comet_ml_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/confident_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/context_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/fiddler_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/flyte_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/human.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/infino_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/labelstudio_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/llmonitor_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/manager.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/mlflow_callback.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/openai_info.cpython-313.pyc +0 -0
- python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/promptlayer_callback.cpython-313.pyc +0 -0
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/ainetwork/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""AINetwork toolkit."""
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/ainetwork/toolkit.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import TYPE_CHECKING, Any, List, Literal, Optional
|
| 4 |
+
|
| 5 |
+
from langchain_core.tools import BaseTool
|
| 6 |
+
from langchain_core.tools.base import BaseToolkit
|
| 7 |
+
from pydantic import ConfigDict, model_validator
|
| 8 |
+
|
| 9 |
+
from langchain_community.tools.ainetwork.app import AINAppOps
|
| 10 |
+
from langchain_community.tools.ainetwork.owner import AINOwnerOps
|
| 11 |
+
from langchain_community.tools.ainetwork.rule import AINRuleOps
|
| 12 |
+
from langchain_community.tools.ainetwork.transfer import AINTransfer
|
| 13 |
+
from langchain_community.tools.ainetwork.utils import authenticate
|
| 14 |
+
from langchain_community.tools.ainetwork.value import AINValueOps
|
| 15 |
+
|
| 16 |
+
if TYPE_CHECKING:
|
| 17 |
+
from ain.ain import Ain
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class AINetworkToolkit(BaseToolkit):
|
| 21 |
+
"""Toolkit for interacting with AINetwork Blockchain.
|
| 22 |
+
|
| 23 |
+
*Security Note*: This toolkit contains tools that can read and modify
|
| 24 |
+
the state of a service; e.g., by reading, creating, updating, deleting
|
| 25 |
+
data associated with this service.
|
| 26 |
+
|
| 27 |
+
See https://python.langchain.com/docs/security for more information.
|
| 28 |
+
|
| 29 |
+
Parameters:
|
| 30 |
+
network: Optional. The network to connect to. Default is "testnet".
|
| 31 |
+
Options are "mainnet" or "testnet".
|
| 32 |
+
interface: Optional. The interface to use. If not provided, will
|
| 33 |
+
attempt to authenticate with the network. Default is None.
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
network: Optional[Literal["mainnet", "testnet"]] = "testnet"
|
| 37 |
+
interface: Optional[Ain] = None
|
| 38 |
+
|
| 39 |
+
@model_validator(mode="before")
|
| 40 |
+
@classmethod
|
| 41 |
+
def set_interface(cls, values: dict) -> Any:
|
| 42 |
+
"""Set the interface if not provided.
|
| 43 |
+
|
| 44 |
+
If the interface is not provided, attempt to authenticate with the
|
| 45 |
+
network using the network value provided.
|
| 46 |
+
|
| 47 |
+
Args:
|
| 48 |
+
values: The values to validate.
|
| 49 |
+
|
| 50 |
+
Returns:
|
| 51 |
+
The validated values.
|
| 52 |
+
"""
|
| 53 |
+
if not values.get("interface"):
|
| 54 |
+
values["interface"] = authenticate(network=values.get("network", "testnet"))
|
| 55 |
+
return values
|
| 56 |
+
|
| 57 |
+
model_config = ConfigDict(
|
| 58 |
+
arbitrary_types_allowed=True,
|
| 59 |
+
validate_default=True,
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
def get_tools(self) -> List[BaseTool]:
|
| 63 |
+
"""Get the tools in the toolkit."""
|
| 64 |
+
return [
|
| 65 |
+
AINAppOps(),
|
| 66 |
+
AINOwnerOps(),
|
| 67 |
+
AINRuleOps(),
|
| 68 |
+
AINTransfer(),
|
| 69 |
+
AINValueOps(),
|
| 70 |
+
]
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/amadeus/__init__.py
ADDED
|
File without changes
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/amadeus/toolkit.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import TYPE_CHECKING, List, Optional
|
| 4 |
+
|
| 5 |
+
from langchain_core.language_models import BaseLanguageModel
|
| 6 |
+
from langchain_core.tools import BaseTool
|
| 7 |
+
from langchain_core.tools.base import BaseToolkit
|
| 8 |
+
from pydantic import ConfigDict, Field
|
| 9 |
+
|
| 10 |
+
from langchain_community.tools.amadeus.closest_airport import AmadeusClosestAirport
|
| 11 |
+
from langchain_community.tools.amadeus.flight_search import AmadeusFlightSearch
|
| 12 |
+
from langchain_community.tools.amadeus.utils import authenticate
|
| 13 |
+
|
| 14 |
+
if TYPE_CHECKING:
|
| 15 |
+
from amadeus import Client
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class AmadeusToolkit(BaseToolkit):
|
| 19 |
+
"""Toolkit for interacting with Amadeus which offers APIs for travel.
|
| 20 |
+
|
| 21 |
+
Parameters:
|
| 22 |
+
client: Optional. The Amadeus client. Default is None.
|
| 23 |
+
llm: Optional. The language model to use. Default is None.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
client: Client = Field(default_factory=authenticate)
|
| 27 |
+
llm: Optional[BaseLanguageModel] = Field(default=None)
|
| 28 |
+
|
| 29 |
+
model_config = ConfigDict(
|
| 30 |
+
arbitrary_types_allowed=True,
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
def get_tools(self) -> List[BaseTool]:
|
| 34 |
+
"""Get the tools in the toolkit."""
|
| 35 |
+
return [
|
| 36 |
+
AmadeusClosestAirport(llm=self.llm),
|
| 37 |
+
AmadeusFlightSearch(),
|
| 38 |
+
]
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/cassandra_database/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Apache Cassandra Toolkit."""
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/cassandra_database/toolkit.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Apache Cassandra Toolkit."""
|
| 2 |
+
|
| 3 |
+
from typing import List
|
| 4 |
+
|
| 5 |
+
from langchain_core.tools import BaseTool
|
| 6 |
+
from langchain_core.tools.base import BaseToolkit
|
| 7 |
+
from pydantic import ConfigDict, Field
|
| 8 |
+
|
| 9 |
+
from langchain_community.tools.cassandra_database.tool import (
|
| 10 |
+
GetSchemaCassandraDatabaseTool,
|
| 11 |
+
GetTableDataCassandraDatabaseTool,
|
| 12 |
+
QueryCassandraDatabaseTool,
|
| 13 |
+
)
|
| 14 |
+
from langchain_community.utilities.cassandra_database import CassandraDatabase
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class CassandraDatabaseToolkit(BaseToolkit):
|
| 18 |
+
"""Toolkit for interacting with an Apache Cassandra database.
|
| 19 |
+
|
| 20 |
+
Parameters:
|
| 21 |
+
db: CassandraDatabase. The Cassandra database to interact
|
| 22 |
+
with.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
db: CassandraDatabase = Field(exclude=True)
|
| 26 |
+
|
| 27 |
+
model_config = ConfigDict(
|
| 28 |
+
arbitrary_types_allowed=True,
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
def get_tools(self) -> List[BaseTool]:
|
| 32 |
+
"""Get the tools in the toolkit."""
|
| 33 |
+
return [
|
| 34 |
+
GetSchemaCassandraDatabaseTool(db=self.db),
|
| 35 |
+
QueryCassandraDatabaseTool(db=self.db),
|
| 36 |
+
GetTableDataCassandraDatabaseTool(db=self.db),
|
| 37 |
+
]
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/clickup/__init__.py
ADDED
|
File without changes
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/clickup/toolkit.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Dict, List
|
| 2 |
+
|
| 3 |
+
from langchain_core.tools import BaseTool
|
| 4 |
+
from langchain_core.tools.base import BaseToolkit
|
| 5 |
+
|
| 6 |
+
from langchain_community.tools.clickup.prompt import (
|
| 7 |
+
CLICKUP_FOLDER_CREATE_PROMPT,
|
| 8 |
+
CLICKUP_GET_ALL_TEAMS_PROMPT,
|
| 9 |
+
CLICKUP_GET_FOLDERS_PROMPT,
|
| 10 |
+
CLICKUP_GET_LIST_PROMPT,
|
| 11 |
+
CLICKUP_GET_SPACES_PROMPT,
|
| 12 |
+
CLICKUP_GET_TASK_ATTRIBUTE_PROMPT,
|
| 13 |
+
CLICKUP_GET_TASK_PROMPT,
|
| 14 |
+
CLICKUP_LIST_CREATE_PROMPT,
|
| 15 |
+
CLICKUP_TASK_CREATE_PROMPT,
|
| 16 |
+
CLICKUP_UPDATE_TASK_ASSIGNEE_PROMPT,
|
| 17 |
+
CLICKUP_UPDATE_TASK_PROMPT,
|
| 18 |
+
)
|
| 19 |
+
from langchain_community.tools.clickup.tool import ClickupAction
|
| 20 |
+
from langchain_community.utilities.clickup import ClickupAPIWrapper
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class ClickupToolkit(BaseToolkit):
|
| 24 |
+
"""Clickup Toolkit.
|
| 25 |
+
|
| 26 |
+
*Security Note*: This toolkit contains tools that can read and modify
|
| 27 |
+
the state of a service; e.g., by reading, creating, updating, deleting
|
| 28 |
+
data associated with this service.
|
| 29 |
+
|
| 30 |
+
See https://python.langchain.com/docs/security for more information.
|
| 31 |
+
|
| 32 |
+
Parameters:
|
| 33 |
+
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
tools: List[BaseTool] = []
|
| 37 |
+
|
| 38 |
+
@classmethod
|
| 39 |
+
def from_clickup_api_wrapper(
|
| 40 |
+
cls, clickup_api_wrapper: ClickupAPIWrapper
|
| 41 |
+
) -> "ClickupToolkit":
|
| 42 |
+
"""Create a ClickupToolkit from a ClickupAPIWrapper.
|
| 43 |
+
|
| 44 |
+
Args:
|
| 45 |
+
clickup_api_wrapper: ClickupAPIWrapper. The Clickup API wrapper.
|
| 46 |
+
|
| 47 |
+
Returns:
|
| 48 |
+
ClickupToolkit. The Clickup toolkit.
|
| 49 |
+
"""
|
| 50 |
+
operations: List[Dict] = [
|
| 51 |
+
{
|
| 52 |
+
"mode": "get_task",
|
| 53 |
+
"name": "Get task",
|
| 54 |
+
"description": CLICKUP_GET_TASK_PROMPT,
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"mode": "get_task_attribute",
|
| 58 |
+
"name": "Get task attribute",
|
| 59 |
+
"description": CLICKUP_GET_TASK_ATTRIBUTE_PROMPT,
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"mode": "get_teams",
|
| 63 |
+
"name": "Get Teams",
|
| 64 |
+
"description": CLICKUP_GET_ALL_TEAMS_PROMPT,
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"mode": "create_task",
|
| 68 |
+
"name": "Create Task",
|
| 69 |
+
"description": CLICKUP_TASK_CREATE_PROMPT,
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"mode": "create_list",
|
| 73 |
+
"name": "Create List",
|
| 74 |
+
"description": CLICKUP_LIST_CREATE_PROMPT,
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"mode": "create_folder",
|
| 78 |
+
"name": "Create Folder",
|
| 79 |
+
"description": CLICKUP_FOLDER_CREATE_PROMPT,
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"mode": "get_list",
|
| 83 |
+
"name": "Get all lists in the space",
|
| 84 |
+
"description": CLICKUP_GET_LIST_PROMPT,
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"mode": "get_folders",
|
| 88 |
+
"name": "Get all folders in the workspace",
|
| 89 |
+
"description": CLICKUP_GET_FOLDERS_PROMPT,
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"mode": "get_spaces",
|
| 93 |
+
"name": "Get all spaces in the workspace",
|
| 94 |
+
"description": CLICKUP_GET_SPACES_PROMPT,
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"mode": "update_task",
|
| 98 |
+
"name": "Update task",
|
| 99 |
+
"description": CLICKUP_UPDATE_TASK_PROMPT,
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"mode": "update_task_assignees",
|
| 103 |
+
"name": "Update task assignees",
|
| 104 |
+
"description": CLICKUP_UPDATE_TASK_ASSIGNEE_PROMPT,
|
| 105 |
+
},
|
| 106 |
+
]
|
| 107 |
+
tools = [
|
| 108 |
+
ClickupAction(
|
| 109 |
+
name=action["name"],
|
| 110 |
+
description=action["description"],
|
| 111 |
+
mode=action["mode"],
|
| 112 |
+
api_wrapper=clickup_api_wrapper,
|
| 113 |
+
)
|
| 114 |
+
for action in operations
|
| 115 |
+
]
|
| 116 |
+
return cls(tools=tools) # type: ignore[arg-type]
|
| 117 |
+
|
| 118 |
+
def get_tools(self) -> List[BaseTool]:
|
| 119 |
+
"""Get the tools in the toolkit."""
|
| 120 |
+
return self.tools
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/cogniswitch/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""CogniSwitch Toolkit"""
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/cogniswitch/toolkit.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List
|
| 2 |
+
|
| 3 |
+
from langchain_core.tools import BaseTool
|
| 4 |
+
from langchain_core.tools.base import BaseToolkit
|
| 5 |
+
|
| 6 |
+
from langchain_community.tools.cogniswitch.tool import (
|
| 7 |
+
CogniswitchKnowledgeRequest,
|
| 8 |
+
CogniswitchKnowledgeSourceFile,
|
| 9 |
+
CogniswitchKnowledgeSourceURL,
|
| 10 |
+
CogniswitchKnowledgeStatus,
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class CogniswitchToolkit(BaseToolkit):
|
| 15 |
+
"""Toolkit for CogniSwitch.
|
| 16 |
+
|
| 17 |
+
Use the toolkit to get all the tools present in the Cogniswitch and
|
| 18 |
+
use them to interact with your knowledge.
|
| 19 |
+
|
| 20 |
+
Parameters:
|
| 21 |
+
cs_token: str. The Cogniswitch token.
|
| 22 |
+
OAI_token: str. The OpenAI API token.
|
| 23 |
+
apiKey: str. The Cogniswitch OAuth token.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
cs_token: str
|
| 27 |
+
OAI_token: str
|
| 28 |
+
apiKey: str
|
| 29 |
+
|
| 30 |
+
def get_tools(self) -> List[BaseTool]:
|
| 31 |
+
"""Get the tools in the toolkit."""
|
| 32 |
+
return [
|
| 33 |
+
CogniswitchKnowledgeStatus(
|
| 34 |
+
cs_token=self.cs_token, OAI_token=self.OAI_token, apiKey=self.apiKey
|
| 35 |
+
),
|
| 36 |
+
CogniswitchKnowledgeRequest(
|
| 37 |
+
cs_token=self.cs_token, OAI_token=self.OAI_token, apiKey=self.apiKey
|
| 38 |
+
),
|
| 39 |
+
CogniswitchKnowledgeSourceFile(
|
| 40 |
+
cs_token=self.cs_token, OAI_token=self.OAI_token, apiKey=self.apiKey
|
| 41 |
+
),
|
| 42 |
+
CogniswitchKnowledgeSourceURL(
|
| 43 |
+
cs_token=self.cs_token, OAI_token=self.OAI_token, apiKey=self.apiKey
|
| 44 |
+
),
|
| 45 |
+
]
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/connery/__init__.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This module contains the ConneryToolkit.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from .toolkit import ConneryToolkit
|
| 6 |
+
|
| 7 |
+
__all__ = ["ConneryToolkit"]
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/connery/toolkit.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any, List
|
| 2 |
+
|
| 3 |
+
from langchain_core.tools import BaseTool
|
| 4 |
+
from langchain_core.tools.base import BaseToolkit
|
| 5 |
+
from pydantic import model_validator
|
| 6 |
+
|
| 7 |
+
from langchain_community.tools.connery import ConneryService
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class ConneryToolkit(BaseToolkit):
|
| 11 |
+
"""
|
| 12 |
+
Toolkit with a list of Connery Actions as tools.
|
| 13 |
+
|
| 14 |
+
Parameters:
|
| 15 |
+
tools (List[BaseTool]): The list of Connery Actions.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
tools: List[BaseTool]
|
| 19 |
+
|
| 20 |
+
def get_tools(self) -> List[BaseTool]:
|
| 21 |
+
"""
|
| 22 |
+
Returns the list of Connery Actions.
|
| 23 |
+
"""
|
| 24 |
+
return self.tools
|
| 25 |
+
|
| 26 |
+
@model_validator(mode="before")
|
| 27 |
+
@classmethod
|
| 28 |
+
def validate_attributes(cls, values: dict) -> Any:
|
| 29 |
+
"""
|
| 30 |
+
Validate the attributes of the ConneryToolkit class.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
values (dict): The arguments to validate.
|
| 34 |
+
Returns:
|
| 35 |
+
dict: The validated arguments.
|
| 36 |
+
|
| 37 |
+
Raises:
|
| 38 |
+
ValueError: If the 'tools' attribute is not set
|
| 39 |
+
"""
|
| 40 |
+
|
| 41 |
+
if not values.get("tools"):
|
| 42 |
+
raise ValueError("The attribute 'tools' must be set.")
|
| 43 |
+
|
| 44 |
+
return values
|
| 45 |
+
|
| 46 |
+
@classmethod
|
| 47 |
+
def create_instance(cls, connery_service: ConneryService) -> "ConneryToolkit":
|
| 48 |
+
"""
|
| 49 |
+
Creates a Connery Toolkit using a Connery Service.
|
| 50 |
+
|
| 51 |
+
Parameters:
|
| 52 |
+
connery_service (ConneryService): The Connery Service
|
| 53 |
+
to get the list of Connery Actions.
|
| 54 |
+
Returns:
|
| 55 |
+
ConneryToolkit: The Connery Toolkit.
|
| 56 |
+
"""
|
| 57 |
+
|
| 58 |
+
instance = cls(tools=connery_service.list_actions()) # type: ignore[arg-type]
|
| 59 |
+
|
| 60 |
+
return instance
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/csv/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
from typing import Any
|
| 3 |
+
|
| 4 |
+
from langchain_core._api.path import as_import_path
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def __getattr__(name: str) -> Any:
|
| 8 |
+
"""Get attr name."""
|
| 9 |
+
|
| 10 |
+
if name == "create_csv_agent":
|
| 11 |
+
# Get directory of langchain package
|
| 12 |
+
HERE = Path(__file__).parents[3]
|
| 13 |
+
here = as_import_path(Path(__file__).parent, relative_to=HERE)
|
| 14 |
+
|
| 15 |
+
old_path = "langchain." + here + "." + name
|
| 16 |
+
new_path = "langchain_experimental." + here + "." + name
|
| 17 |
+
raise ImportError(
|
| 18 |
+
"This agent has been moved to langchain experiment. "
|
| 19 |
+
"This agent relies on python REPL tool under the hood, so to use it "
|
| 20 |
+
"safely please sandbox the python REPL. "
|
| 21 |
+
"Read https://github.com/langchain-ai/langchain/blob/master/SECURITY.md "
|
| 22 |
+
"and https://github.com/langchain-ai/langchain/discussions/11680"
|
| 23 |
+
"To keep using this code as is, install langchain experimental and "
|
| 24 |
+
f"update your import statement from:\n `{old_path}` to `{new_path}`."
|
| 25 |
+
)
|
| 26 |
+
raise AttributeError(f"{name} does not exist")
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/file_management/__init__.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Local file management toolkit."""
|
| 2 |
+
|
| 3 |
+
from langchain_community.agent_toolkits.file_management.toolkit import (
|
| 4 |
+
FileManagementToolkit,
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
__all__ = ["FileManagementToolkit"]
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/file_management/toolkit.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import Any, Dict, List, Optional, Type
|
| 4 |
+
|
| 5 |
+
from langchain_core.tools import BaseTool, BaseToolkit
|
| 6 |
+
from langchain_core.utils.pydantic import get_fields
|
| 7 |
+
from pydantic import model_validator
|
| 8 |
+
|
| 9 |
+
from langchain_community.tools.file_management.copy import CopyFileTool
|
| 10 |
+
from langchain_community.tools.file_management.delete import DeleteFileTool
|
| 11 |
+
from langchain_community.tools.file_management.file_search import FileSearchTool
|
| 12 |
+
from langchain_community.tools.file_management.list_dir import ListDirectoryTool
|
| 13 |
+
from langchain_community.tools.file_management.move import MoveFileTool
|
| 14 |
+
from langchain_community.tools.file_management.read import ReadFileTool
|
| 15 |
+
from langchain_community.tools.file_management.write import WriteFileTool
|
| 16 |
+
|
| 17 |
+
_FILE_TOOLS: List[Type[BaseTool]] = [
|
| 18 |
+
CopyFileTool,
|
| 19 |
+
DeleteFileTool,
|
| 20 |
+
FileSearchTool,
|
| 21 |
+
MoveFileTool,
|
| 22 |
+
ReadFileTool,
|
| 23 |
+
WriteFileTool,
|
| 24 |
+
ListDirectoryTool,
|
| 25 |
+
]
|
| 26 |
+
_FILE_TOOLS_MAP: Dict[str, Type[BaseTool]] = {
|
| 27 |
+
get_fields(tool_cls)["name"].default: tool_cls for tool_cls in _FILE_TOOLS
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class FileManagementToolkit(BaseToolkit):
|
| 32 |
+
"""Toolkit for interacting with local files.
|
| 33 |
+
|
| 34 |
+
*Security Notice*: This toolkit provides methods to interact with local files.
|
| 35 |
+
If providing this toolkit to an agent on an LLM, ensure you scope
|
| 36 |
+
the agent's permissions to only include the necessary permissions
|
| 37 |
+
to perform the desired operations.
|
| 38 |
+
|
| 39 |
+
By **default** the agent will have access to all files within
|
| 40 |
+
the root dir and will be able to Copy, Delete, Move, Read, Write
|
| 41 |
+
and List files in that directory.
|
| 42 |
+
|
| 43 |
+
Consider the following:
|
| 44 |
+
- Limit access to particular directories using `root_dir`.
|
| 45 |
+
- Use filesystem permissions to restrict access and permissions to only
|
| 46 |
+
the files and directories required by the agent.
|
| 47 |
+
- Limit the tools available to the agent to only the file operations
|
| 48 |
+
necessary for the agent's intended use.
|
| 49 |
+
- Sandbox the agent by running it in a container.
|
| 50 |
+
|
| 51 |
+
See https://python.langchain.com/docs/security for more information.
|
| 52 |
+
|
| 53 |
+
Parameters:
|
| 54 |
+
root_dir: Optional. The root directory to perform file operations.
|
| 55 |
+
If not provided, file operations are performed relative to the current
|
| 56 |
+
working directory.
|
| 57 |
+
selected_tools: Optional. The tools to include in the toolkit. If not
|
| 58 |
+
provided, all tools are included.
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
root_dir: Optional[str] = None
|
| 62 |
+
"""If specified, all file operations are made relative to root_dir."""
|
| 63 |
+
selected_tools: Optional[List[str]] = None
|
| 64 |
+
"""If provided, only provide the selected tools. Defaults to all."""
|
| 65 |
+
|
| 66 |
+
@model_validator(mode="before")
|
| 67 |
+
@classmethod
|
| 68 |
+
def validate_tools(cls, values: dict) -> Any:
|
| 69 |
+
selected_tools = values.get("selected_tools") or []
|
| 70 |
+
for tool_name in selected_tools:
|
| 71 |
+
if tool_name not in _FILE_TOOLS_MAP:
|
| 72 |
+
raise ValueError(
|
| 73 |
+
f"File Tool of name {tool_name} not supported."
|
| 74 |
+
f" Permitted tools: {list(_FILE_TOOLS_MAP)}"
|
| 75 |
+
)
|
| 76 |
+
return values
|
| 77 |
+
|
| 78 |
+
def get_tools(self) -> List[BaseTool]:
|
| 79 |
+
"""Get the tools in the toolkit."""
|
| 80 |
+
allowed_tools = self.selected_tools or _FILE_TOOLS_MAP
|
| 81 |
+
tools: List[BaseTool] = []
|
| 82 |
+
for tool in allowed_tools:
|
| 83 |
+
tool_cls = _FILE_TOOLS_MAP[tool]
|
| 84 |
+
tools.append(tool_cls(root_dir=self.root_dir))
|
| 85 |
+
return tools
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
__all__ = ["FileManagementToolkit"]
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/financial_datasets/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""financial datasets toolkit."""
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/financial_datasets/toolkit.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import List
|
| 4 |
+
|
| 5 |
+
from langchain_core.tools import BaseTool
|
| 6 |
+
from langchain_core.tools.base import BaseToolkit
|
| 7 |
+
from pydantic import ConfigDict, Field
|
| 8 |
+
|
| 9 |
+
from langchain_community.tools.financial_datasets.balance_sheets import BalanceSheets
|
| 10 |
+
from langchain_community.tools.financial_datasets.cash_flow_statements import (
|
| 11 |
+
CashFlowStatements,
|
| 12 |
+
)
|
| 13 |
+
from langchain_community.tools.financial_datasets.income_statements import (
|
| 14 |
+
IncomeStatements,
|
| 15 |
+
)
|
| 16 |
+
from langchain_community.utilities.financial_datasets import FinancialDatasetsAPIWrapper
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class FinancialDatasetsToolkit(BaseToolkit):
|
| 20 |
+
"""Toolkit for interacting with financialdatasets.ai.
|
| 21 |
+
|
| 22 |
+
Parameters:
|
| 23 |
+
api_wrapper: The FinancialDatasets API Wrapper.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
api_wrapper: FinancialDatasetsAPIWrapper = Field(
|
| 27 |
+
default_factory=FinancialDatasetsAPIWrapper
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
def __init__(self, api_wrapper: FinancialDatasetsAPIWrapper):
|
| 31 |
+
super().__init__()
|
| 32 |
+
self.api_wrapper = api_wrapper
|
| 33 |
+
|
| 34 |
+
model_config = ConfigDict(
|
| 35 |
+
arbitrary_types_allowed=True,
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
def get_tools(self) -> List[BaseTool]:
|
| 39 |
+
"""Get the tools in the toolkit."""
|
| 40 |
+
return [
|
| 41 |
+
BalanceSheets(api_wrapper=self.api_wrapper),
|
| 42 |
+
CashFlowStatements(api_wrapper=self.api_wrapper),
|
| 43 |
+
IncomeStatements(api_wrapper=self.api_wrapper),
|
| 44 |
+
]
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/github/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""GitHub Toolkit."""
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/github/toolkit.py
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""GitHub Toolkit."""
|
| 2 |
+
|
| 3 |
+
from typing import Dict, List
|
| 4 |
+
|
| 5 |
+
from langchain_core.tools import BaseTool
|
| 6 |
+
from langchain_core.tools.base import BaseToolkit
|
| 7 |
+
from pydantic import BaseModel, Field
|
| 8 |
+
|
| 9 |
+
from langchain_community.tools.github.prompt import (
|
| 10 |
+
COMMENT_ON_ISSUE_PROMPT,
|
| 11 |
+
CREATE_BRANCH_PROMPT,
|
| 12 |
+
CREATE_FILE_PROMPT,
|
| 13 |
+
CREATE_PULL_REQUEST_PROMPT,
|
| 14 |
+
CREATE_REVIEW_REQUEST_PROMPT,
|
| 15 |
+
DELETE_FILE_PROMPT,
|
| 16 |
+
GET_FILES_FROM_DIRECTORY_PROMPT,
|
| 17 |
+
GET_ISSUE_PROMPT,
|
| 18 |
+
GET_ISSUES_PROMPT,
|
| 19 |
+
GET_LATEST_RELEASE_PROMPT,
|
| 20 |
+
GET_PR_PROMPT,
|
| 21 |
+
GET_RELEASE_PROMPT,
|
| 22 |
+
GET_RELEASES_PROMPT,
|
| 23 |
+
LIST_BRANCHES_IN_REPO_PROMPT,
|
| 24 |
+
LIST_PRS_PROMPT,
|
| 25 |
+
LIST_PULL_REQUEST_FILES,
|
| 26 |
+
OVERVIEW_EXISTING_FILES_BOT_BRANCH,
|
| 27 |
+
OVERVIEW_EXISTING_FILES_IN_MAIN,
|
| 28 |
+
READ_FILE_PROMPT,
|
| 29 |
+
SEARCH_CODE_PROMPT,
|
| 30 |
+
SEARCH_ISSUES_AND_PRS_PROMPT,
|
| 31 |
+
SET_ACTIVE_BRANCH_PROMPT,
|
| 32 |
+
UPDATE_FILE_PROMPT,
|
| 33 |
+
)
|
| 34 |
+
from langchain_community.tools.github.tool import GitHubAction
|
| 35 |
+
from langchain_community.utilities.github import GitHubAPIWrapper
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class NoInput(BaseModel):
|
| 39 |
+
"""Schema for operations that do not require any input."""
|
| 40 |
+
|
| 41 |
+
no_input: str = Field("", description="No input required, e.g. `` (empty string).")
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class GetIssue(BaseModel):
|
| 45 |
+
"""Schema for operations that require an issue number as input."""
|
| 46 |
+
|
| 47 |
+
issue_number: int = Field(0, description="Issue number as an integer, e.g. `42`")
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class CommentOnIssue(BaseModel):
|
| 51 |
+
"""Schema for operations that require a comment as input."""
|
| 52 |
+
|
| 53 |
+
input: str = Field(..., description="Follow the required formatting.")
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class GetPR(BaseModel):
|
| 57 |
+
"""Schema for operations that require a PR number as input."""
|
| 58 |
+
|
| 59 |
+
pr_number: int = Field(0, description="The PR number as an integer, e.g. `12`")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
class CreatePR(BaseModel):
|
| 63 |
+
"""Schema for operations that require a PR title and body as input."""
|
| 64 |
+
|
| 65 |
+
formatted_pr: str = Field(..., description="Follow the required formatting.")
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
class CreateFile(BaseModel):
|
| 69 |
+
"""Schema for operations that require a file path and content as input."""
|
| 70 |
+
|
| 71 |
+
formatted_file: str = Field(..., description="Follow the required formatting.")
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class ReadFile(BaseModel):
|
| 75 |
+
"""Schema for operations that require a file path as input."""
|
| 76 |
+
|
| 77 |
+
formatted_filepath: str = Field(
|
| 78 |
+
...,
|
| 79 |
+
description=(
|
| 80 |
+
"The full file path of the file you would like to read where the "
|
| 81 |
+
"path must NOT start with a slash, e.g. `some_dir/my_file.py`."
|
| 82 |
+
),
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
class UpdateFile(BaseModel):
|
| 87 |
+
"""Schema for operations that require a file path and content as input."""
|
| 88 |
+
|
| 89 |
+
formatted_file_update: str = Field(
|
| 90 |
+
..., description="Strictly follow the provided rules."
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
class DeleteFile(BaseModel):
|
| 95 |
+
"""Schema for operations that require a file path as input."""
|
| 96 |
+
|
| 97 |
+
formatted_filepath: str = Field(
|
| 98 |
+
...,
|
| 99 |
+
description=(
|
| 100 |
+
"The full file path of the file you would like to delete"
|
| 101 |
+
" where the path must NOT start with a slash, e.g."
|
| 102 |
+
" `some_dir/my_file.py`. Only input a string,"
|
| 103 |
+
" not the param name."
|
| 104 |
+
),
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
class DirectoryPath(BaseModel):
|
| 109 |
+
"""Schema for operations that require a directory path as input."""
|
| 110 |
+
|
| 111 |
+
input: str = Field(
|
| 112 |
+
"",
|
| 113 |
+
description=(
|
| 114 |
+
"The path of the directory, e.g. `some_dir/inner_dir`."
|
| 115 |
+
" Only input a string, do not include the parameter name."
|
| 116 |
+
),
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
class BranchName(BaseModel):
|
| 121 |
+
"""Schema for operations that require a branch name as input."""
|
| 122 |
+
|
| 123 |
+
branch_name: str = Field(
|
| 124 |
+
..., description="The name of the branch, e.g. `my_branch`."
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
class SearchCode(BaseModel):
|
| 129 |
+
"""Schema for operations that require a search query as input."""
|
| 130 |
+
|
| 131 |
+
search_query: str = Field(
|
| 132 |
+
...,
|
| 133 |
+
description=(
|
| 134 |
+
"A keyword-focused natural language search"
|
| 135 |
+
"query for code, e.g. `MyFunctionName()`."
|
| 136 |
+
),
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
class CreateReviewRequest(BaseModel):
|
| 141 |
+
"""Schema for operations that require a username as input."""
|
| 142 |
+
|
| 143 |
+
username: str = Field(
|
| 144 |
+
...,
|
| 145 |
+
description="GitHub username of the user being requested, e.g. `my_username`.",
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
class SearchIssuesAndPRs(BaseModel):
|
| 150 |
+
"""Schema for operations that require a search query as input."""
|
| 151 |
+
|
| 152 |
+
search_query: str = Field(
|
| 153 |
+
...,
|
| 154 |
+
description="Natural language search query, e.g. `My issue title or topic`.",
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
class TagName(BaseModel):
|
| 159 |
+
"""Schema for operations that require a tag name as input."""
|
| 160 |
+
|
| 161 |
+
tag_name: str = Field(
|
| 162 |
+
...,
|
| 163 |
+
description="The tag name of the release, e.g. `v1.0.0`.",
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
class GitHubToolkit(BaseToolkit):
|
| 168 |
+
"""GitHub Toolkit.
|
| 169 |
+
|
| 170 |
+
*Security Note*: This toolkit contains tools that can read and modify
|
| 171 |
+
the state of a service; e.g., by creating, deleting, or updating,
|
| 172 |
+
reading underlying data.
|
| 173 |
+
|
| 174 |
+
For example, this toolkit can be used to create issues, pull requests,
|
| 175 |
+
and comments on GitHub.
|
| 176 |
+
|
| 177 |
+
See [Security](https://python.langchain.com/docs/security) for more information.
|
| 178 |
+
|
| 179 |
+
Setup:
|
| 180 |
+
See detailed installation instructions here:
|
| 181 |
+
https://python.langchain.com/docs/integrations/tools/github/#installation
|
| 182 |
+
|
| 183 |
+
You will need to install ``pygithub`` and set the following environment
|
| 184 |
+
variables:
|
| 185 |
+
|
| 186 |
+
.. code-block:: bash
|
| 187 |
+
|
| 188 |
+
pip install -U pygithub
|
| 189 |
+
export GITHUB_APP_ID="your-app-id"
|
| 190 |
+
export GITHUB_APP_PRIVATE_KEY="path-to-private-key"
|
| 191 |
+
export GITHUB_REPOSITORY="your-github-repository"
|
| 192 |
+
|
| 193 |
+
Instantiate:
|
| 194 |
+
.. code-block:: python
|
| 195 |
+
|
| 196 |
+
from langchain_community.agent_toolkits.github.toolkit import GitHubToolkit
|
| 197 |
+
from langchain_community.utilities.github import GitHubAPIWrapper
|
| 198 |
+
|
| 199 |
+
github = GitHubAPIWrapper()
|
| 200 |
+
toolkit = GitHubToolkit.from_github_api_wrapper(github)
|
| 201 |
+
|
| 202 |
+
Tools:
|
| 203 |
+
.. code-block:: python
|
| 204 |
+
|
| 205 |
+
tools = toolkit.get_tools()
|
| 206 |
+
for tool in tools:
|
| 207 |
+
print(tool.name)
|
| 208 |
+
|
| 209 |
+
.. code-block:: none
|
| 210 |
+
|
| 211 |
+
Get Issues
|
| 212 |
+
Get Issue
|
| 213 |
+
Comment on Issue
|
| 214 |
+
List open pull requests (PRs)
|
| 215 |
+
Get Pull Request
|
| 216 |
+
Overview of files included in PR
|
| 217 |
+
Create Pull Request
|
| 218 |
+
List Pull Requests' Files
|
| 219 |
+
Create File
|
| 220 |
+
Read File
|
| 221 |
+
Update File
|
| 222 |
+
Delete File
|
| 223 |
+
Overview of existing files in Main branch
|
| 224 |
+
Overview of files in current working branch
|
| 225 |
+
List branches in this repository
|
| 226 |
+
Set active branch
|
| 227 |
+
Create a new branch
|
| 228 |
+
Get files from a directory
|
| 229 |
+
Search issues and pull requests
|
| 230 |
+
Search code
|
| 231 |
+
Create review request
|
| 232 |
+
|
| 233 |
+
Include release tools:
|
| 234 |
+
By default, the toolkit does not include release-related tools.
|
| 235 |
+
You can include them by setting ``include_release_tools=True`` when
|
| 236 |
+
initializing the toolkit:
|
| 237 |
+
|
| 238 |
+
.. code-block:: python
|
| 239 |
+
|
| 240 |
+
toolkit = GitHubToolkit.from_github_api_wrapper(
|
| 241 |
+
github, include_release_tools=True
|
| 242 |
+
)
|
| 243 |
+
|
| 244 |
+
Setting ``include_release_tools=True`` will include the following tools:
|
| 245 |
+
|
| 246 |
+
.. code-block:: none
|
| 247 |
+
|
| 248 |
+
Get latest release
|
| 249 |
+
Get releases
|
| 250 |
+
Get release
|
| 251 |
+
|
| 252 |
+
Use within an agent:
|
| 253 |
+
.. code-block:: python
|
| 254 |
+
|
| 255 |
+
from langchain_openai import ChatOpenAI
|
| 256 |
+
from langgraph.prebuilt import create_react_agent
|
| 257 |
+
|
| 258 |
+
# Select example tool
|
| 259 |
+
tools = [tool for tool in toolkit.get_tools() if tool.name == "Get Issue"]
|
| 260 |
+
assert len(tools) == 1
|
| 261 |
+
tools[0].name = "get_issue"
|
| 262 |
+
|
| 263 |
+
llm = ChatOpenAI(model="gpt-4o-mini")
|
| 264 |
+
agent_executor = create_react_agent(llm, tools)
|
| 265 |
+
|
| 266 |
+
example_query = "What is the title of issue 24888?"
|
| 267 |
+
|
| 268 |
+
events = agent_executor.stream(
|
| 269 |
+
{"messages": [("user", example_query)]},
|
| 270 |
+
stream_mode="values",
|
| 271 |
+
)
|
| 272 |
+
for event in events:
|
| 273 |
+
event["messages"][-1].pretty_print()
|
| 274 |
+
|
| 275 |
+
.. code-block:: none
|
| 276 |
+
|
| 277 |
+
================================[1m Human Message [0m=================================
|
| 278 |
+
|
| 279 |
+
What is the title of issue 24888?
|
| 280 |
+
==================================[1m Ai Message [0m==================================
|
| 281 |
+
Tool Calls:
|
| 282 |
+
get_issue (call_iSYJVaM7uchfNHOMJoVPQsOi)
|
| 283 |
+
Call ID: call_iSYJVaM7uchfNHOMJoVPQsOi
|
| 284 |
+
Args:
|
| 285 |
+
issue_number: 24888
|
| 286 |
+
=================================[1m Tool Message [0m=================================
|
| 287 |
+
Name: get_issue
|
| 288 |
+
|
| 289 |
+
{"number": 24888, "title": "Standardize KV-Store Docs", "body": "..."
|
| 290 |
+
==================================[1m Ai Message [0m==================================
|
| 291 |
+
|
| 292 |
+
The title of issue 24888 is "Standardize KV-Store Docs".
|
| 293 |
+
|
| 294 |
+
Parameters:
|
| 295 |
+
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
|
| 296 |
+
""" # noqa: E501
|
| 297 |
+
|
| 298 |
+
tools: List[BaseTool] = []
|
| 299 |
+
|
| 300 |
+
@classmethod
|
| 301 |
+
def from_github_api_wrapper(
|
| 302 |
+
cls, github_api_wrapper: GitHubAPIWrapper, include_release_tools: bool = False
|
| 303 |
+
) -> "GitHubToolkit":
|
| 304 |
+
"""Create a GitHubToolkit from a GitHubAPIWrapper.
|
| 305 |
+
|
| 306 |
+
Args:
|
| 307 |
+
github_api_wrapper: GitHubAPIWrapper. The GitHub API wrapper.
|
| 308 |
+
include_release_tools: bool. Whether to include release-related tools.
|
| 309 |
+
Defaults to False.
|
| 310 |
+
|
| 311 |
+
Returns:
|
| 312 |
+
GitHubToolkit. The GitHub toolkit.
|
| 313 |
+
"""
|
| 314 |
+
operations: List[Dict] = [
|
| 315 |
+
{
|
| 316 |
+
"mode": "get_issues",
|
| 317 |
+
"name": "Get Issues",
|
| 318 |
+
"description": GET_ISSUES_PROMPT,
|
| 319 |
+
"args_schema": NoInput,
|
| 320 |
+
},
|
| 321 |
+
{
|
| 322 |
+
"mode": "get_issue",
|
| 323 |
+
"name": "Get Issue",
|
| 324 |
+
"description": GET_ISSUE_PROMPT,
|
| 325 |
+
"args_schema": GetIssue,
|
| 326 |
+
},
|
| 327 |
+
{
|
| 328 |
+
"mode": "comment_on_issue",
|
| 329 |
+
"name": "Comment on Issue",
|
| 330 |
+
"description": COMMENT_ON_ISSUE_PROMPT,
|
| 331 |
+
"args_schema": CommentOnIssue,
|
| 332 |
+
},
|
| 333 |
+
{
|
| 334 |
+
"mode": "list_open_pull_requests",
|
| 335 |
+
"name": "List open pull requests (PRs)",
|
| 336 |
+
"description": LIST_PRS_PROMPT,
|
| 337 |
+
"args_schema": NoInput,
|
| 338 |
+
},
|
| 339 |
+
{
|
| 340 |
+
"mode": "get_pull_request",
|
| 341 |
+
"name": "Get Pull Request",
|
| 342 |
+
"description": GET_PR_PROMPT,
|
| 343 |
+
"args_schema": GetPR,
|
| 344 |
+
},
|
| 345 |
+
{
|
| 346 |
+
"mode": "list_pull_request_files",
|
| 347 |
+
"name": "Overview of files included in PR",
|
| 348 |
+
"description": LIST_PULL_REQUEST_FILES,
|
| 349 |
+
"args_schema": GetPR,
|
| 350 |
+
},
|
| 351 |
+
{
|
| 352 |
+
"mode": "create_pull_request",
|
| 353 |
+
"name": "Create Pull Request",
|
| 354 |
+
"description": CREATE_PULL_REQUEST_PROMPT,
|
| 355 |
+
"args_schema": CreatePR,
|
| 356 |
+
},
|
| 357 |
+
{
|
| 358 |
+
"mode": "list_pull_request_files",
|
| 359 |
+
"name": "List Pull Requests' Files",
|
| 360 |
+
"description": LIST_PULL_REQUEST_FILES,
|
| 361 |
+
"args_schema": GetPR,
|
| 362 |
+
},
|
| 363 |
+
{
|
| 364 |
+
"mode": "create_file",
|
| 365 |
+
"name": "Create File",
|
| 366 |
+
"description": CREATE_FILE_PROMPT,
|
| 367 |
+
"args_schema": CreateFile,
|
| 368 |
+
},
|
| 369 |
+
{
|
| 370 |
+
"mode": "read_file",
|
| 371 |
+
"name": "Read File",
|
| 372 |
+
"description": READ_FILE_PROMPT,
|
| 373 |
+
"args_schema": ReadFile,
|
| 374 |
+
},
|
| 375 |
+
{
|
| 376 |
+
"mode": "update_file",
|
| 377 |
+
"name": "Update File",
|
| 378 |
+
"description": UPDATE_FILE_PROMPT,
|
| 379 |
+
"args_schema": UpdateFile,
|
| 380 |
+
},
|
| 381 |
+
{
|
| 382 |
+
"mode": "delete_file",
|
| 383 |
+
"name": "Delete File",
|
| 384 |
+
"description": DELETE_FILE_PROMPT,
|
| 385 |
+
"args_schema": DeleteFile,
|
| 386 |
+
},
|
| 387 |
+
{
|
| 388 |
+
"mode": "list_files_in_main_branch",
|
| 389 |
+
"name": "Overview of existing files in Main branch",
|
| 390 |
+
"description": OVERVIEW_EXISTING_FILES_IN_MAIN,
|
| 391 |
+
"args_schema": NoInput,
|
| 392 |
+
},
|
| 393 |
+
{
|
| 394 |
+
"mode": "list_files_in_bot_branch",
|
| 395 |
+
"name": "Overview of files in current working branch",
|
| 396 |
+
"description": OVERVIEW_EXISTING_FILES_BOT_BRANCH,
|
| 397 |
+
"args_schema": NoInput,
|
| 398 |
+
},
|
| 399 |
+
{
|
| 400 |
+
"mode": "list_branches_in_repo",
|
| 401 |
+
"name": "List branches in this repository",
|
| 402 |
+
"description": LIST_BRANCHES_IN_REPO_PROMPT,
|
| 403 |
+
"args_schema": NoInput,
|
| 404 |
+
},
|
| 405 |
+
{
|
| 406 |
+
"mode": "set_active_branch",
|
| 407 |
+
"name": "Set active branch",
|
| 408 |
+
"description": SET_ACTIVE_BRANCH_PROMPT,
|
| 409 |
+
"args_schema": BranchName,
|
| 410 |
+
},
|
| 411 |
+
{
|
| 412 |
+
"mode": "create_branch",
|
| 413 |
+
"name": "Create a new branch",
|
| 414 |
+
"description": CREATE_BRANCH_PROMPT,
|
| 415 |
+
"args_schema": BranchName,
|
| 416 |
+
},
|
| 417 |
+
{
|
| 418 |
+
"mode": "get_files_from_directory",
|
| 419 |
+
"name": "Get files from a directory",
|
| 420 |
+
"description": GET_FILES_FROM_DIRECTORY_PROMPT,
|
| 421 |
+
"args_schema": DirectoryPath,
|
| 422 |
+
},
|
| 423 |
+
{
|
| 424 |
+
"mode": "search_issues_and_prs",
|
| 425 |
+
"name": "Search issues and pull requests",
|
| 426 |
+
"description": SEARCH_ISSUES_AND_PRS_PROMPT,
|
| 427 |
+
"args_schema": SearchIssuesAndPRs,
|
| 428 |
+
},
|
| 429 |
+
{
|
| 430 |
+
"mode": "search_code",
|
| 431 |
+
"name": "Search code",
|
| 432 |
+
"description": SEARCH_CODE_PROMPT,
|
| 433 |
+
"args_schema": SearchCode,
|
| 434 |
+
},
|
| 435 |
+
{
|
| 436 |
+
"mode": "create_review_request",
|
| 437 |
+
"name": "Create review request",
|
| 438 |
+
"description": CREATE_REVIEW_REQUEST_PROMPT,
|
| 439 |
+
"args_schema": CreateReviewRequest,
|
| 440 |
+
},
|
| 441 |
+
]
|
| 442 |
+
|
| 443 |
+
release_operations: List[Dict] = [
|
| 444 |
+
{
|
| 445 |
+
"mode": "get_latest_release",
|
| 446 |
+
"name": "Get latest release",
|
| 447 |
+
"description": GET_LATEST_RELEASE_PROMPT,
|
| 448 |
+
"args_schema": NoInput,
|
| 449 |
+
},
|
| 450 |
+
{
|
| 451 |
+
"mode": "get_releases",
|
| 452 |
+
"name": "Get releases",
|
| 453 |
+
"description": GET_RELEASES_PROMPT,
|
| 454 |
+
"args_schema": NoInput,
|
| 455 |
+
},
|
| 456 |
+
{
|
| 457 |
+
"mode": "get_release",
|
| 458 |
+
"name": "Get release",
|
| 459 |
+
"description": GET_RELEASE_PROMPT,
|
| 460 |
+
"args_schema": TagName,
|
| 461 |
+
},
|
| 462 |
+
]
|
| 463 |
+
|
| 464 |
+
operations = operations + (release_operations if include_release_tools else [])
|
| 465 |
+
tools = [
|
| 466 |
+
GitHubAction(
|
| 467 |
+
name=action["name"],
|
| 468 |
+
description=action["description"],
|
| 469 |
+
mode=action["mode"],
|
| 470 |
+
api_wrapper=github_api_wrapper,
|
| 471 |
+
args_schema=action.get("args_schema", None),
|
| 472 |
+
)
|
| 473 |
+
for action in operations
|
| 474 |
+
]
|
| 475 |
+
return cls(tools=tools) # type: ignore[arg-type]
|
| 476 |
+
|
| 477 |
+
def get_tools(self) -> List[BaseTool]:
|
| 478 |
+
"""Get the tools in the toolkit."""
|
| 479 |
+
return self.tools
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/gitlab/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""GitLab Toolkit."""
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/gitlab/toolkit.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""GitLab Toolkit."""
|
| 2 |
+
|
| 3 |
+
from typing import Dict, List, Optional
|
| 4 |
+
|
| 5 |
+
from langchain_core.tools import BaseTool
|
| 6 |
+
from langchain_core.tools.base import BaseToolkit
|
| 7 |
+
|
| 8 |
+
from langchain_community.tools.gitlab.prompt import (
|
| 9 |
+
COMMENT_ON_ISSUE_PROMPT,
|
| 10 |
+
CREATE_FILE_PROMPT,
|
| 11 |
+
CREATE_PULL_REQUEST_PROMPT,
|
| 12 |
+
CREATE_REPO_BRANCH,
|
| 13 |
+
DELETE_FILE_PROMPT,
|
| 14 |
+
GET_ISSUE_PROMPT,
|
| 15 |
+
GET_ISSUES_PROMPT,
|
| 16 |
+
GET_REPO_FILES_FROM_DIRECTORY,
|
| 17 |
+
GET_REPO_FILES_IN_BOT_BRANCH,
|
| 18 |
+
GET_REPO_FILES_IN_MAIN,
|
| 19 |
+
LIST_REPO_BRANCES,
|
| 20 |
+
READ_FILE_PROMPT,
|
| 21 |
+
SET_ACTIVE_BRANCH,
|
| 22 |
+
UPDATE_FILE_PROMPT,
|
| 23 |
+
)
|
| 24 |
+
from langchain_community.tools.gitlab.tool import GitLabAction
|
| 25 |
+
from langchain_community.utilities.gitlab import GitLabAPIWrapper
|
| 26 |
+
|
| 27 |
+
# only include a subset of tools by default to avoid a breaking change, where
|
| 28 |
+
# new tools are added to the toolkit and the user's code breaks because of
|
| 29 |
+
# the new tools
|
| 30 |
+
DEFAULT_INCLUDED_TOOLS = [
|
| 31 |
+
"get_issues",
|
| 32 |
+
"get_issue",
|
| 33 |
+
"comment_on_issue",
|
| 34 |
+
"create_pull_request",
|
| 35 |
+
"create_file",
|
| 36 |
+
"read_file",
|
| 37 |
+
"update_file",
|
| 38 |
+
"delete_file",
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class GitLabToolkit(BaseToolkit):
|
| 43 |
+
"""GitLab Toolkit.
|
| 44 |
+
|
| 45 |
+
*Security Note*: This toolkit contains tools that can read and modify
|
| 46 |
+
the state of a service; e.g., by creating, deleting, or updating,
|
| 47 |
+
reading underlying data.
|
| 48 |
+
|
| 49 |
+
For example, this toolkit can be used to create issues, pull requests,
|
| 50 |
+
and comments on GitLab.
|
| 51 |
+
|
| 52 |
+
See https://python.langchain.com/docs/security for more information.
|
| 53 |
+
|
| 54 |
+
Parameters:
|
| 55 |
+
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
|
| 56 |
+
"""
|
| 57 |
+
|
| 58 |
+
tools: List[BaseTool] = []
|
| 59 |
+
|
| 60 |
+
@classmethod
|
| 61 |
+
def from_gitlab_api_wrapper(
|
| 62 |
+
cls,
|
| 63 |
+
gitlab_api_wrapper: GitLabAPIWrapper,
|
| 64 |
+
*,
|
| 65 |
+
included_tools: Optional[List[str]] = None,
|
| 66 |
+
) -> "GitLabToolkit":
|
| 67 |
+
"""Create a GitLabToolkit from a GitLabAPIWrapper.
|
| 68 |
+
|
| 69 |
+
Args:
|
| 70 |
+
gitlab_api_wrapper: GitLabAPIWrapper. The GitLab API wrapper.
|
| 71 |
+
|
| 72 |
+
Returns:
|
| 73 |
+
GitLabToolkit. The GitLab toolkit.
|
| 74 |
+
"""
|
| 75 |
+
|
| 76 |
+
tools_to_include = (
|
| 77 |
+
included_tools if included_tools is not None else DEFAULT_INCLUDED_TOOLS
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
operations: List[Dict] = [
|
| 81 |
+
{
|
| 82 |
+
"mode": "get_issues",
|
| 83 |
+
"name": "Get Issues",
|
| 84 |
+
"description": GET_ISSUES_PROMPT,
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"mode": "get_issue",
|
| 88 |
+
"name": "Get Issue",
|
| 89 |
+
"description": GET_ISSUE_PROMPT,
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"mode": "comment_on_issue",
|
| 93 |
+
"name": "Comment on Issue",
|
| 94 |
+
"description": COMMENT_ON_ISSUE_PROMPT,
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"mode": "create_pull_request",
|
| 98 |
+
"name": "Create Pull Request",
|
| 99 |
+
"description": CREATE_PULL_REQUEST_PROMPT,
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"mode": "create_file",
|
| 103 |
+
"name": "Create File",
|
| 104 |
+
"description": CREATE_FILE_PROMPT,
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"mode": "read_file",
|
| 108 |
+
"name": "Read File",
|
| 109 |
+
"description": READ_FILE_PROMPT,
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"mode": "update_file",
|
| 113 |
+
"name": "Update File",
|
| 114 |
+
"description": UPDATE_FILE_PROMPT,
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"mode": "delete_file",
|
| 118 |
+
"name": "Delete File",
|
| 119 |
+
"description": DELETE_FILE_PROMPT,
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"mode": "create_branch",
|
| 123 |
+
"name": "Create a new branch",
|
| 124 |
+
"description": CREATE_REPO_BRANCH,
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"mode": "list_branches_in_repo",
|
| 128 |
+
"name": "Get the list of branches",
|
| 129 |
+
"description": LIST_REPO_BRANCES,
|
| 130 |
+
},
|
| 131 |
+
{
|
| 132 |
+
"mode": "set_active_branch",
|
| 133 |
+
"name": "Change the active branch",
|
| 134 |
+
"description": SET_ACTIVE_BRANCH,
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
"mode": "list_files_in_main_branch",
|
| 138 |
+
"name": "Overview of existing files in Main branch",
|
| 139 |
+
"description": GET_REPO_FILES_IN_MAIN,
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"mode": "list_files_in_bot_branch",
|
| 143 |
+
"name": "Overview of files in current working branch",
|
| 144 |
+
"description": GET_REPO_FILES_IN_BOT_BRANCH,
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"mode": "list_files_from_directory",
|
| 148 |
+
"name": "Overview of files in current working branch from a specific path", # noqa: E501
|
| 149 |
+
"description": GET_REPO_FILES_FROM_DIRECTORY,
|
| 150 |
+
},
|
| 151 |
+
]
|
| 152 |
+
operations_filtered = [
|
| 153 |
+
operation
|
| 154 |
+
for operation in operations
|
| 155 |
+
if operation["mode"] in tools_to_include
|
| 156 |
+
]
|
| 157 |
+
tools = [
|
| 158 |
+
GitLabAction(
|
| 159 |
+
name=action["name"],
|
| 160 |
+
description=action["description"],
|
| 161 |
+
mode=action["mode"],
|
| 162 |
+
api_wrapper=gitlab_api_wrapper,
|
| 163 |
+
)
|
| 164 |
+
for action in operations_filtered
|
| 165 |
+
]
|
| 166 |
+
return cls(tools=tools) # type: ignore[arg-type]
|
| 167 |
+
|
| 168 |
+
def get_tools(self) -> List[BaseTool]:
|
| 169 |
+
"""Get the tools in the toolkit."""
|
| 170 |
+
return self.tools
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/gmail/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Gmail toolkit."""
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/gmail/toolkit.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import TYPE_CHECKING, List
|
| 4 |
+
|
| 5 |
+
from langchain_core.tools import BaseTool
|
| 6 |
+
from langchain_core.tools.base import BaseToolkit
|
| 7 |
+
from pydantic import ConfigDict, Field
|
| 8 |
+
|
| 9 |
+
from langchain_community.tools.gmail.create_draft import GmailCreateDraft
|
| 10 |
+
from langchain_community.tools.gmail.get_message import GmailGetMessage
|
| 11 |
+
from langchain_community.tools.gmail.get_thread import GmailGetThread
|
| 12 |
+
from langchain_community.tools.gmail.search import GmailSearch
|
| 13 |
+
from langchain_community.tools.gmail.send_message import GmailSendMessage
|
| 14 |
+
from langchain_community.tools.gmail.utils import build_resource_service
|
| 15 |
+
|
| 16 |
+
if TYPE_CHECKING:
|
| 17 |
+
# This is for linting and IDE typehints
|
| 18 |
+
from googleapiclient.discovery import Resource
|
| 19 |
+
else:
|
| 20 |
+
try:
|
| 21 |
+
# We do this so pydantic can resolve the types when instantiating
|
| 22 |
+
from googleapiclient.discovery import Resource
|
| 23 |
+
except ImportError:
|
| 24 |
+
pass
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
SCOPES = ["https://mail.google.com/"]
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class GmailToolkit(BaseToolkit):
|
| 31 |
+
"""Toolkit for interacting with Gmail.
|
| 32 |
+
|
| 33 |
+
*Security Note*: This toolkit contains tools that can read and modify
|
| 34 |
+
the state of a service; e.g., by reading, creating, updating, deleting
|
| 35 |
+
data associated with this service.
|
| 36 |
+
|
| 37 |
+
For example, this toolkit can be used to send emails on behalf of the
|
| 38 |
+
associated account.
|
| 39 |
+
|
| 40 |
+
See https://python.langchain.com/docs/security for more information.
|
| 41 |
+
|
| 42 |
+
Setup:
|
| 43 |
+
You will need a Google credentials.json file to use this toolkit.
|
| 44 |
+
See instructions here: https://python.langchain.com/docs/integrations/tools/gmail/#setup
|
| 45 |
+
|
| 46 |
+
Key init args:
|
| 47 |
+
api_resource: Optional. The Google API resource. Default is None.
|
| 48 |
+
|
| 49 |
+
Instantiate:
|
| 50 |
+
.. code-block:: python
|
| 51 |
+
|
| 52 |
+
from langchain_google_community import GmailToolkit
|
| 53 |
+
|
| 54 |
+
toolkit = GmailToolkit()
|
| 55 |
+
|
| 56 |
+
Tools:
|
| 57 |
+
.. code-block:: python
|
| 58 |
+
|
| 59 |
+
toolkit.get_tools()
|
| 60 |
+
|
| 61 |
+
.. code-block:: none
|
| 62 |
+
|
| 63 |
+
[GmailCreateDraft(api_resource=<googleapiclient.discovery.Resource object at 0x1094509d0>),
|
| 64 |
+
GmailSendMessage(api_resource=<googleapiclient.discovery.Resource object at 0x1094509d0>),
|
| 65 |
+
GmailSearch(api_resource=<googleapiclient.discovery.Resource object at 0x1094509d0>),
|
| 66 |
+
GmailGetMessage(api_resource=<googleapiclient.discovery.Resource object at 0x1094509d0>),
|
| 67 |
+
GmailGetThread(api_resource=<googleapiclient.discovery.Resource object at 0x1094509d0>)]
|
| 68 |
+
|
| 69 |
+
Use within an agent:
|
| 70 |
+
.. code-block:: python
|
| 71 |
+
|
| 72 |
+
from langchain_openai import ChatOpenAI
|
| 73 |
+
from langgraph.prebuilt import create_react_agent
|
| 74 |
+
|
| 75 |
+
llm = ChatOpenAI(model="gpt-4o-mini")
|
| 76 |
+
|
| 77 |
+
agent_executor = create_react_agent(llm, tools)
|
| 78 |
+
|
| 79 |
+
example_query = "Draft an email to fake@fake.com thanking them for coffee."
|
| 80 |
+
|
| 81 |
+
events = agent_executor.stream(
|
| 82 |
+
{"messages": [("user", example_query)]},
|
| 83 |
+
stream_mode="values",
|
| 84 |
+
)
|
| 85 |
+
for event in events:
|
| 86 |
+
event["messages"][-1].pretty_print()
|
| 87 |
+
|
| 88 |
+
.. code-block:: none
|
| 89 |
+
|
| 90 |
+
================================[1m Human Message [0m=================================
|
| 91 |
+
|
| 92 |
+
Draft an email to fake@fake.com thanking them for coffee.
|
| 93 |
+
==================================[1m Ai Message [0m==================================
|
| 94 |
+
Tool Calls:
|
| 95 |
+
create_gmail_draft (call_slGkYKZKA6h3Mf1CraUBzs6M)
|
| 96 |
+
Call ID: call_slGkYKZKA6h3Mf1CraUBzs6M
|
| 97 |
+
Args:
|
| 98 |
+
message: Dear Fake,
|
| 99 |
+
|
| 100 |
+
I wanted to take a moment to thank you for the coffee yesterday. It was a pleasure catching up with you. Let's do it again soon!
|
| 101 |
+
|
| 102 |
+
Best regards,
|
| 103 |
+
[Your Name]
|
| 104 |
+
to: ['fake@fake.com']
|
| 105 |
+
subject: Thank You for the Coffee
|
| 106 |
+
=================================[1m Tool Message [0m=================================
|
| 107 |
+
Name: create_gmail_draft
|
| 108 |
+
|
| 109 |
+
Draft created. Draft Id: r-7233782721440261513
|
| 110 |
+
==================================[1m Ai Message [0m==================================
|
| 111 |
+
|
| 112 |
+
I have drafted an email to fake@fake.com thanking them for the coffee. You can review and send it from your email draft with the subject "Thank You for the Coffee".
|
| 113 |
+
|
| 114 |
+
Parameters:
|
| 115 |
+
api_resource: Optional. The Google API resource. Default is None.
|
| 116 |
+
""" # noqa: E501
|
| 117 |
+
|
| 118 |
+
api_resource: Resource = Field(default_factory=build_resource_service)
|
| 119 |
+
|
| 120 |
+
model_config = ConfigDict(
|
| 121 |
+
arbitrary_types_allowed=True,
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
def get_tools(self) -> List[BaseTool]:
|
| 125 |
+
"""Get the tools in the toolkit."""
|
| 126 |
+
return [
|
| 127 |
+
GmailCreateDraft(api_resource=self.api_resource),
|
| 128 |
+
GmailSendMessage(api_resource=self.api_resource),
|
| 129 |
+
GmailSearch(api_resource=self.api_resource),
|
| 130 |
+
GmailGetMessage(api_resource=self.api_resource),
|
| 131 |
+
GmailGetThread(api_resource=self.api_resource),
|
| 132 |
+
]
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/jira/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Jira Toolkit."""
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/jira/toolkit.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Dict, List
|
| 2 |
+
|
| 3 |
+
from langchain_core.tools import BaseTool
|
| 4 |
+
from langchain_core.tools.base import BaseToolkit
|
| 5 |
+
|
| 6 |
+
from langchain_community.tools.jira.prompt import (
|
| 7 |
+
JIRA_CATCH_ALL_PROMPT,
|
| 8 |
+
JIRA_CONFLUENCE_PAGE_CREATE_PROMPT,
|
| 9 |
+
JIRA_GET_ALL_PROJECTS_PROMPT,
|
| 10 |
+
JIRA_ISSUE_CREATE_PROMPT,
|
| 11 |
+
JIRA_JQL_PROMPT,
|
| 12 |
+
)
|
| 13 |
+
from langchain_community.tools.jira.tool import JiraAction
|
| 14 |
+
from langchain_community.utilities.jira import JiraAPIWrapper
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class JiraToolkit(BaseToolkit):
|
| 18 |
+
"""Jira Toolkit.
|
| 19 |
+
|
| 20 |
+
*Security Note*: This toolkit contains tools that can read and modify
|
| 21 |
+
the state of a service; e.g., by creating, deleting, or updating,
|
| 22 |
+
reading underlying data.
|
| 23 |
+
|
| 24 |
+
See https://python.langchain.com/docs/security for more information.
|
| 25 |
+
|
| 26 |
+
Parameters:
|
| 27 |
+
tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
tools: List[BaseTool] = []
|
| 31 |
+
|
| 32 |
+
@classmethod
|
| 33 |
+
def from_jira_api_wrapper(cls, jira_api_wrapper: JiraAPIWrapper) -> "JiraToolkit":
|
| 34 |
+
"""Create a JiraToolkit from a JiraAPIWrapper.
|
| 35 |
+
|
| 36 |
+
Args:
|
| 37 |
+
jira_api_wrapper: JiraAPIWrapper. The Jira API wrapper.
|
| 38 |
+
|
| 39 |
+
Returns:
|
| 40 |
+
JiraToolkit. The Jira toolkit.
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
operations: List[Dict] = [
|
| 44 |
+
{
|
| 45 |
+
"mode": "jql",
|
| 46 |
+
"name": "jql_query",
|
| 47 |
+
"description": JIRA_JQL_PROMPT,
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"mode": "get_projects",
|
| 51 |
+
"name": "get_projects",
|
| 52 |
+
"description": JIRA_GET_ALL_PROJECTS_PROMPT,
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"mode": "create_issue",
|
| 56 |
+
"name": "create_issue",
|
| 57 |
+
"description": JIRA_ISSUE_CREATE_PROMPT,
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"mode": "other",
|
| 61 |
+
"name": "catch_all_jira_api",
|
| 62 |
+
"description": JIRA_CATCH_ALL_PROMPT,
|
| 63 |
+
},
|
| 64 |
+
{
|
| 65 |
+
"mode": "create_page",
|
| 66 |
+
"name": "create_confluence_page",
|
| 67 |
+
"description": JIRA_CONFLUENCE_PAGE_CREATE_PROMPT,
|
| 68 |
+
},
|
| 69 |
+
]
|
| 70 |
+
tools = [
|
| 71 |
+
JiraAction(
|
| 72 |
+
name=action["name"],
|
| 73 |
+
description=action["description"],
|
| 74 |
+
mode=action["mode"],
|
| 75 |
+
api_wrapper=jira_api_wrapper,
|
| 76 |
+
)
|
| 77 |
+
for action in operations
|
| 78 |
+
]
|
| 79 |
+
return cls(tools=tools) # type: ignore[arg-type]
|
| 80 |
+
|
| 81 |
+
def get_tools(self) -> List[BaseTool]:
|
| 82 |
+
"""Get the tools in the toolkit."""
|
| 83 |
+
return self.tools
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/json/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Json agent."""
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/json/base.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Json agent."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
| 6 |
+
|
| 7 |
+
from langchain_core.callbacks import BaseCallbackManager
|
| 8 |
+
from langchain_core.language_models import BaseLanguageModel
|
| 9 |
+
|
| 10 |
+
from langchain_community.agent_toolkits.json.prompt import JSON_PREFIX, JSON_SUFFIX
|
| 11 |
+
from langchain_community.agent_toolkits.json.toolkit import JsonToolkit
|
| 12 |
+
|
| 13 |
+
if TYPE_CHECKING:
|
| 14 |
+
from langchain_classic.agents.agent import AgentExecutor
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def create_json_agent(
|
| 18 |
+
llm: BaseLanguageModel,
|
| 19 |
+
toolkit: JsonToolkit,
|
| 20 |
+
callback_manager: Optional[BaseCallbackManager] = None,
|
| 21 |
+
prefix: str = JSON_PREFIX,
|
| 22 |
+
suffix: str = JSON_SUFFIX,
|
| 23 |
+
format_instructions: Optional[str] = None,
|
| 24 |
+
input_variables: Optional[List[str]] = None,
|
| 25 |
+
verbose: bool = False,
|
| 26 |
+
agent_executor_kwargs: Optional[Dict[str, Any]] = None,
|
| 27 |
+
**kwargs: Any,
|
| 28 |
+
) -> AgentExecutor:
|
| 29 |
+
"""Construct a json agent from an LLM and tools.
|
| 30 |
+
|
| 31 |
+
Args:
|
| 32 |
+
llm: The language model to use.
|
| 33 |
+
toolkit: The toolkit to use.
|
| 34 |
+
callback_manager: The callback manager to use. Default is None.
|
| 35 |
+
prefix: The prefix to use. Default is JSON_PREFIX.
|
| 36 |
+
suffix: The suffix to use. Default is JSON_SUFFIX.
|
| 37 |
+
format_instructions: The format instructions to use. Default is None.
|
| 38 |
+
input_variables: The input variables to use. Default is None.
|
| 39 |
+
verbose: Whether to print verbose output. Default is False.
|
| 40 |
+
agent_executor_kwargs: Optional additional arguments for the agent executor.
|
| 41 |
+
kwargs: Additional arguments for the agent.
|
| 42 |
+
|
| 43 |
+
Returns:
|
| 44 |
+
The agent executor.
|
| 45 |
+
"""
|
| 46 |
+
from langchain_classic.agents.agent import AgentExecutor
|
| 47 |
+
from langchain_classic.agents.mrkl.base import ZeroShotAgent
|
| 48 |
+
from langchain_classic.chains.llm import LLMChain
|
| 49 |
+
|
| 50 |
+
tools = toolkit.get_tools()
|
| 51 |
+
prompt_params = (
|
| 52 |
+
{"format_instructions": format_instructions}
|
| 53 |
+
if format_instructions is not None
|
| 54 |
+
else {}
|
| 55 |
+
)
|
| 56 |
+
prompt = ZeroShotAgent.create_prompt(
|
| 57 |
+
tools,
|
| 58 |
+
prefix=prefix,
|
| 59 |
+
suffix=suffix,
|
| 60 |
+
input_variables=input_variables,
|
| 61 |
+
**prompt_params,
|
| 62 |
+
)
|
| 63 |
+
llm_chain = LLMChain(
|
| 64 |
+
llm=llm,
|
| 65 |
+
prompt=prompt,
|
| 66 |
+
callback_manager=callback_manager,
|
| 67 |
+
)
|
| 68 |
+
tool_names = [tool.name for tool in tools]
|
| 69 |
+
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names, **kwargs)
|
| 70 |
+
return AgentExecutor.from_agent_and_tools(
|
| 71 |
+
agent=agent,
|
| 72 |
+
tools=tools,
|
| 73 |
+
callback_manager=callback_manager,
|
| 74 |
+
verbose=verbose,
|
| 75 |
+
**(agent_executor_kwargs or {}),
|
| 76 |
+
)
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/json/prompt.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# flake8: noqa
|
| 2 |
+
|
| 3 |
+
JSON_PREFIX = """You are an agent designed to interact with JSON.
|
| 4 |
+
Your goal is to return a final answer by interacting with the JSON.
|
| 5 |
+
You have access to the following tools which help you learn more about the JSON you are interacting with.
|
| 6 |
+
Only use the below tools. Only use the information returned by the below tools to construct your final answer.
|
| 7 |
+
Do not make up any information that is not contained in the JSON.
|
| 8 |
+
Your input to the tools should be in the form of `data["key"][0]` where `data` is the JSON blob you are interacting with, and the syntax used is Python.
|
| 9 |
+
You should only use keys that you know for a fact exist. You must validate that a key exists by seeing it previously when calling `json_spec_list_keys`.
|
| 10 |
+
If you have not seen a key in one of those responses, you cannot use it.
|
| 11 |
+
You should only add one key at a time to the path. You cannot add multiple keys at once.
|
| 12 |
+
If you encounter a "KeyError", go back to the previous key, look at the available keys, and try again.
|
| 13 |
+
|
| 14 |
+
If the question does not seem to be related to the JSON, just return "I don't know" as the answer.
|
| 15 |
+
Always begin your interaction with the `json_spec_list_keys` tool with input "data" to see what keys exist in the JSON.
|
| 16 |
+
|
| 17 |
+
Note that sometimes the value at a given path is large. In this case, you will get an error "Value is a large dictionary, should explore its keys directly".
|
| 18 |
+
In this case, you should ALWAYS follow up by using the `json_spec_list_keys` tool to see what keys exist at that path.
|
| 19 |
+
Do not simply refer the user to the JSON or a section of the JSON, as this is not a valid answer. Keep digging until you find the answer and explicitly return it.
|
| 20 |
+
"""
|
| 21 |
+
JSON_SUFFIX = """Begin!"
|
| 22 |
+
|
| 23 |
+
Question: {input}
|
| 24 |
+
Thought: I should look at the keys that exist in data to see what I have access to
|
| 25 |
+
{agent_scratchpad}"""
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/json/toolkit.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import List
|
| 4 |
+
|
| 5 |
+
from langchain_core.tools import BaseTool
|
| 6 |
+
from langchain_core.tools.base import BaseToolkit
|
| 7 |
+
|
| 8 |
+
from langchain_community.tools.json.tool import (
|
| 9 |
+
JsonGetValueTool,
|
| 10 |
+
JsonListKeysTool,
|
| 11 |
+
JsonSpec,
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class JsonToolkit(BaseToolkit):
|
| 16 |
+
"""Toolkit for interacting with a JSON spec.
|
| 17 |
+
|
| 18 |
+
Parameters:
|
| 19 |
+
spec: The JSON spec.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
spec: JsonSpec
|
| 23 |
+
|
| 24 |
+
def get_tools(self) -> List[BaseTool]:
|
| 25 |
+
"""Get the tools in the toolkit."""
|
| 26 |
+
return [
|
| 27 |
+
JsonListKeysTool(spec=self.spec),
|
| 28 |
+
JsonGetValueTool(spec=self.spec),
|
| 29 |
+
]
|
python/user_packages/Python313/site-packages/langchain_community/agent_toolkits/multion/toolkit.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""MultiOn agent."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import List
|
| 6 |
+
|
| 7 |
+
from langchain_core.tools import BaseTool
|
| 8 |
+
from langchain_core.tools.base import BaseToolkit
|
| 9 |
+
from pydantic import ConfigDict
|
| 10 |
+
|
| 11 |
+
from langchain_community.tools.multion.close_session import MultionCloseSession
|
| 12 |
+
from langchain_community.tools.multion.create_session import MultionCreateSession
|
| 13 |
+
from langchain_community.tools.multion.update_session import MultionUpdateSession
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class MultionToolkit(BaseToolkit):
|
| 17 |
+
"""Toolkit for interacting with the Browser Agent.
|
| 18 |
+
|
| 19 |
+
**Security Note**: This toolkit contains tools that interact with the
|
| 20 |
+
user's browser via the multion API which grants an agent
|
| 21 |
+
access to the user's browser.
|
| 22 |
+
|
| 23 |
+
Please review the documentation for the multion API to understand
|
| 24 |
+
the security implications of using this toolkit.
|
| 25 |
+
|
| 26 |
+
See https://python.langchain.com/docs/security for more information.
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
model_config = ConfigDict(
|
| 30 |
+
arbitrary_types_allowed=True,
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
def get_tools(self) -> List[BaseTool]:
|
| 34 |
+
"""Get the tools in the toolkit."""
|
| 35 |
+
return [MultionCreateSession(), MultionUpdateSession(), MultionCloseSession()]
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (5.18 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/aim_callback.cpython-313.pyc
ADDED
|
Binary file (20.1 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/argilla_callback.cpython-313.pyc
ADDED
|
Binary file (16.6 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/arize_callback.cpython-313.pyc
ADDED
|
Binary file (8.96 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/arthur_callback.cpython-313.pyc
ADDED
|
Binary file (13 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/bedrock_anthropic_callback.cpython-313.pyc
ADDED
|
Binary file (6.27 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/clearml_callback.cpython-313.pyc
ADDED
|
Binary file (25.2 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/comet_ml_callback.cpython-313.pyc
ADDED
|
Binary file (30.8 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/confident_callback.cpython-313.pyc
ADDED
|
Binary file (8.27 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/context_callback.cpython-313.pyc
ADDED
|
Binary file (8.23 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/fiddler_callback.cpython-313.pyc
ADDED
|
Binary file (13.3 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/flyte_callback.cpython-313.pyc
ADDED
|
Binary file (19.7 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/human.cpython-313.pyc
ADDED
|
Binary file (4.26 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/infino_callback.cpython-313.pyc
ADDED
|
Binary file (11.1 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/labelstudio_callback.cpython-313.pyc
ADDED
|
Binary file (16.1 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/llmonitor_callback.cpython-313.pyc
ADDED
|
Binary file (25.6 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/manager.cpython-313.pyc
ADDED
|
Binary file (3.89 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/mlflow_callback.cpython-313.pyc
ADDED
|
Binary file (38.7 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/openai_info.cpython-313.pyc
ADDED
|
Binary file (22.2 kB). View file
|
|
|
python/user_packages/Python313/site-packages/langchain_community/callbacks/__pycache__/promptlayer_callback.cpython-313.pyc
ADDED
|
Binary file (7.37 kB). View file
|
|
|