mirror of
https://github.com/hwchase17/langchain
synced 2024-11-11 19:11:02 +00:00
32c5be8b73
## Summary This PR implements the "Connery Action Tool" and "Connery Toolkit". Using them, you can integrate Connery actions into your LangChain agents and chains. Connery is an open-source plugin infrastructure for AI. With Connery, you can easily create a custom plugin with a set of actions and seamlessly integrate them into your LangChain agents and chains. Connery will handle the rest: runtime, authorization, secret management, access management, audit logs, and other vital features. Additionally, Connery and our community offer a wide range of ready-to-use open-source plugins for your convenience. Learn more about Connery: - GitHub: https://github.com/connery-io/connery-platform - Documentation: https://docs.connery.io - Twitter: https://twitter.com/connery_io ## TODOs - [x] API wrapper - [x] Integration tests - [x] Connery Action Tool - [x] Docs - [x] Example - [x] Integration tests - [x] Connery Toolkit - [x] Docs - [x] Example - [x] Formatting (`make format`) - [x] Linting (`make lint`) - [x] Testing (`make test`)
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
from typing import List
|
|
|
|
from langchain_core.pydantic_v1 import root_validator
|
|
from langchain_core.tools import BaseTool
|
|
|
|
from langchain_community.agent_toolkits.base import BaseToolkit
|
|
from langchain_community.tools.connery import ConneryService
|
|
|
|
|
|
class ConneryToolkit(BaseToolkit):
|
|
"""
|
|
A LangChain Toolkit with a list of Connery Actions as tools.
|
|
"""
|
|
|
|
tools: List[BaseTool]
|
|
|
|
def get_tools(self) -> List[BaseTool]:
|
|
"""
|
|
Returns the list of Connery Actions.
|
|
"""
|
|
return self.tools
|
|
|
|
@root_validator()
|
|
def validate_attributes(cls, values: dict) -> dict:
|
|
"""
|
|
Validate the attributes of the ConneryToolkit class.
|
|
Parameters:
|
|
values (dict): The arguments to validate.
|
|
Returns:
|
|
dict: The validated arguments.
|
|
"""
|
|
|
|
if not values.get("tools"):
|
|
raise ValueError("The attribute 'tools' must be set.")
|
|
|
|
return values
|
|
|
|
@classmethod
|
|
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.
|
|
Returns:
|
|
ConneryToolkit: The Connery Toolkit.
|
|
"""
|
|
|
|
instance = cls(tools=connery_service.list_actions())
|
|
|
|
return instance
|