Connery toolkit과 tools를 사용하면 Connery Actions를 LangChain agent에 통합할 수 있습니다.

Connery란 무엇인가요?

Connery는 AI를 위한 오픈소스 플러그인 인프라입니다. Connery를 사용하면 일련의 actions로 구성된 커스텀 플러그인을 쉽게 생성하고 LangChain agent에 원활하게 통합할 수 있습니다. Connery는 runtime, authorization, secret management, access management, audit logs 및 기타 중요한 기능과 같은 핵심 측면을 처리합니다. 또한 커뮤니티의 지원을 받는 Connery는 편의를 위해 바로 사용할 수 있는 다양한 오픈소스 플러그인 컬렉션을 제공합니다. Connery에 대해 자세히 알아보기:

Setup

Installation

Connery tools를 사용하려면 langchain_community 패키지를 설치해야 합니다.
pip install -qU langchain-community

Credentials

LangChain agent에서 Connery Actions를 사용하려면 몇 가지 준비가 필요합니다:
  1. Quickstart 가이드를 사용하여 Connery runner를 설정합니다.
  2. agent에서 사용하려는 actions가 포함된 모든 플러그인을 설치합니다.
  3. toolkit이 Connery Runner와 통신할 수 있도록 환경 변수 CONNERY_RUNNER_URLCONNERY_RUNNER_API_KEY를 설정합니다.
import getpass
import os

for key in ["CONNERY_RUNNER_URL", "CONNERY_RUNNER_API_KEY"]:
    if key not in os.environ:
        os.environ[key] = getpass.getpass(f"Please enter the value for {key}: ")

Toolkit

아래 예제에서는 두 개의 Connery Actions를 사용하여 공개 웹페이지를 요약하고 이메일로 요약본을 전송하는 agent를 생성합니다:
  1. Summarization 플러그인의 Summarize public webpage action.
  2. Gmail 플러그인의 Send email action.
이 예제의 LangSmith trace는 여기에서 확인할 수 있습니다.
import os

from langchain.agents import AgentType, initialize_agent
from langchain_community.agent_toolkits.connery import ConneryToolkit
from langchain_community.tools.connery import ConneryService
from langchain_openai import ChatOpenAI

# Specify your Connery Runner credentials.
os.environ["CONNERY_RUNNER_URL"] = ""
os.environ["CONNERY_RUNNER_API_KEY"] = ""

# Specify OpenAI API key.
os.environ["OPENAI_API_KEY"] = ""

# Specify your email address to receive the email with the summary from example below.
recepient_email = "[email protected]"

# Create a Connery Toolkit with all the available actions from the Connery Runner.
connery_service = ConneryService()
connery_toolkit = ConneryToolkit.create_instance(connery_service)

# Use OpenAI Functions agent to execute the prompt using actions from the Connery Toolkit.
llm = ChatOpenAI(temperature=0)
agent = initialize_agent(
    connery_toolkit.get_tools(), llm, AgentType.OPENAI_FUNCTIONS, verbose=True
)
result = agent.run(
    f"""Make a short summary of the webpage http://www.paulgraham.com/vb.html in three sentences
and send it to {recepient_email}. Include the link to the webpage into the body of the email."""
)
print(result)
> Entering new AgentExecutor chain...

Invoking: `CA72DFB0AB4DF6C830B43E14B0782F70` with `{'publicWebpageUrl': 'http://www.paulgraham.com/vb.html'}`


{'summary': 'The author reflects on the concept of life being short and how having children made them realize the true brevity of life. They discuss how time can be converted into discrete quantities and how limited certain experiences are. The author emphasizes the importance of prioritizing and eliminating unnecessary things in life, as well as actively pursuing meaningful experiences. They also discuss the negative impact of getting caught up in online arguments and the need to be aware of how time is being spent. The author suggests pruning unnecessary activities, not waiting to do things that matter, and savoring the time one has.'}
Invoking: `CABC80BB79C15067CA983495324AE709` with `{'recipient': '[email protected]', 'subject': 'Summary of the webpage', 'body': 'Here is a short summary of the webpage http://www.paulgraham.com/vb.html:\n\nThe author reflects on the concept of life being short and how having children made them realize the true brevity of life. They discuss how time can be converted into discrete quantities and how limited certain experiences are. The author emphasizes the importance of prioritizing and eliminating unnecessary things in life, as well as actively pursuing meaningful experiences. They also discuss the negative impact of getting caught up in online arguments and the need to be aware of how time is being spent. The author suggests pruning unnecessary activities, not waiting to do things that matter, and savoring the time one has.\n\nYou can find the full webpage [here](http://www.paulgraham.com/vb.html).'}`


{'messageId': '[[email protected]](mailto:[email protected])'}I have sent the email with the summary of the webpage to [email protected]. Please check your inbox.

> Finished chain.
I have sent the email with the summary of the webpage to [email protected]. Please check your inbox.
참고: Connery Action은 structured tool이므로 structured tools를 지원하는 agents에서만 사용할 수 있습니다.

Tool

import os

from langchain.agents import AgentType, initialize_agent
from langchain_community.tools.connery import ConneryService
from langchain_openai import ChatOpenAI

# Specify your Connery Runner credentials.
os.environ["CONNERY_RUNNER_URL"] = ""
os.environ["CONNERY_RUNNER_API_KEY"] = ""

# Specify OpenAI API key.
os.environ["OPENAI_API_KEY"] = ""

# Specify your email address to receive the emails from examples below.
recepient_email = "[email protected]"

# Get the SendEmail action from the Connery Runner by ID.
connery_service = ConneryService()
send_email_action = connery_service.get_action("CABC80BB79C15067CA983495324AE709")
action을 수동으로 실행합니다.
manual_run_result = send_email_action.run(
    {
        "recipient": recepient_email,
        "subject": "Test email",
        "body": "This is a test email sent from Connery.",
    }
)
print(manual_run_result)
OpenAI Functions agent를 사용하여 action을 실행합니다. 이 예제의 LangSmith trace는 여기에서 확인할 수 있습니다.
llm = ChatOpenAI(temperature=0)
agent = initialize_agent(
    [send_email_action], llm, AgentType.OPENAI_FUNCTIONS, verbose=True
)
agent_run_result = agent.run(
    f"Send an email to the {recepient_email} and say that I will be late for the meeting."
)
print(agent_run_result)
> Entering new AgentExecutor chain...

Invoking: `CABC80BB79C15067CA983495324AE709` with `{'recipient': '[email protected]', 'subject': 'Late for Meeting', 'body': 'Dear Team,\n\nI wanted to inform you that I will be late for the meeting today. I apologize for any inconvenience caused. Please proceed with the meeting without me and I will join as soon as I can.\n\nBest regards,\n[Your Name]'}`


{'messageId': '[[email protected]](mailto:[email protected])'}I have sent an email to [email protected] informing them that you will be late for the meeting.

> Finished chain.
I have sent an email to [email protected] informing them that you will be late for the meeting.
참고: Connery Action은 structured tool이므로 structured tools를 지원하는 agents에서만 사용할 수 있습니다.

API reference

모든 Connery 기능 및 구성에 대한 자세한 문서는 API reference를 참조하세요:
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I