사전 구축된 도구 모음 활용
LangChain이 제공하는 사전 구성 도구 모음을 찾아 에이전트에 기능을 빠르게 추가합니다.
사전 구축된 도구 모음 활용은(는) CoddyKit의 무료 AI Agents with LangChain & Autonomous Workflows 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 AI Agents with LangChain & Autonomous Workflows 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. AI Agents with LangChain & Autonomous Workflows 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Intro to Pre-built Toolkits
Welcome to leveraging pre-built toolkits in LangChain! So far, you've learned to define and use individual tools. But what if you need a set of related tools?
Toolkits are collections of pre-configured tools designed for specific purposes. They bundle common functionalities, making it much easier to add powerful capabilities to your AI agents.
Why Use Toolkits?
Using toolkits offers several key advantages:
- Time-saving: No need to define common tools from scratch.
- Reduced Boilerplate: Less code to write and manage.
- Consistency: Ensures tools are implemented correctly and consistently.
- Expanded Capabilities: Instantly equip your agent with complex functionalities like web search, database interaction, or advanced math.
Example: The Math Toolkit
Let's start with a simple yet powerful example: the Math Toolkit. This toolkit provides basic arithmetic operations, allowing your agent to perform calculations.
It's a great way to see how a collection of tools can be integrated and used by an agent to solve problems that require numerical processing.
Initializing a Toolkit
First, you need to import and initialize the toolkit. Here's how you can set up the MathToolkit and inspect the tools it provides:
from langchain_community.agent_toolkits import MathToolkit
def main():
# Initialize the Math Toolkit
toolkit = MathToolkit()
print("MathToolkit initialized!")
print("\nTools available in this toolkit:")
# Iterate and print details of each tool
for tool in toolkit.get_tools():
print(f"- {tool.name}: {tool.description}")
if __name__ == "__main__":
main()Agents Using Toolkits
Once a toolkit is initialized, you pass its collection of tools to your agent, just like you would with individual tools.
The agent's reasoning engine will then intelligently decide which tool from the toolkit is best suited to answer a given query or complete a task.
Agent Solving Math Problems
Watch this agent use the MathToolkit to perform a multiplication. Notice how the agent 'thinks' about the problem and selects the correct tool.
(Remember to replace YOUR_API_KEY with your actual OpenAI API key for the code to run.)
from langchain_community.llms import OpenAI
from langchain.agents import initialize_agent, AgentType
from langchain_community.agent_toolkits import MathToolkit
import os
def main():
# Set your OpenAI API key here
# os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY" # Uncomment and replace
if "OPENAI_API_KEY" not in os.environ:
print("Error: OPENAI_API_KEY environment variable not set.")
print("Please set it to run this example.")
return
llm = OpenAI(temperature=0) # Using a simple LLM
toolkit = MathToolkit()
tools = toolkit.get_tools()
# Initialize the agent with the LLM and the toolkit's tools
agent = initialize_agent(
tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)
print("\nAgent at work (verbose output shows thinking process):\n")
agent.run("What is 12345 * 6789?")
if __name__ == "__main__":
main()Exploring Other Powerful Toolkits
LangChain offers many other pre-built toolkits for diverse tasks:
- Wikipedia Toolkit: For agents needing to search and retrieve information from Wikipedia.
- OpenAPI Toolkit: Allows agents to interact with any API described by an OpenAPI spec.
- SQL Database Toolkit: Enables agents to query and interact with SQL databases.
- Python Agent Toolkit: Allows agents to write and execute Python code.
Each toolkit significantly expands your agent's capabilities!
Discovering More Toolkits
Want to find more toolkits? Here's how:
- LangChain Documentation: The official docs are the best resource.
- Source Code: Explore the
langchain_community.agent_toolkitsmodule directly. - Community Examples: Look at how others are using LangChain in GitHub repos or tutorials.
New toolkits are constantly being developed and added!
Toolkit Quick Check
What is the primary benefit of using pre-built toolkits in LangChain?
Recap: Toolkit Power-Up!
Great job! In this lesson, you learned about:
- What pre-built toolkits are in LangChain.
- The significant benefits they offer, like saving time and expanding capabilities.
- How to initialize and integrate toolkits (like the
MathToolkit) with your agents. - Where to discover more powerful toolkits for various tasks.
Toolkits are a fantastic way to quickly supercharge your agents!
자주 묻는 질문
“사전 구축된 도구 모음 활용” 강의는 무료인가요?
네 — “사전 구축된 도구 모음 활용” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 AI Agents with LangChain & Autonomous Workflows 강의 전체를 잠금 해제할 수 있습니다. AI Agents with LangChain & Autonomous Workflows 강의에는 총 4개의 강의가 포함되어 있습니다.
“사전 구축된 도구 모음 활용”에서 뭘 배우나요?
LangChain이 제공하는 사전 구성 도구 모음을 찾아 에이전트에 기능을 빠르게 추가합니다. 브라우저에서 직접 실행하는 실습 코드로 AI Agents with LangChain & Autonomous Workflows을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
AI Agents with LangChain & Autonomous Workflows을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 AI Agents with LangChain & Autonomous Workflows은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.
“사전 구축된 도구 모음 활용” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 AI Agents with LangChain & Autonomous Workflows 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 AI Agents with LangChain & Autonomous Workflows 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 도구 정의와 사용
- 에이전트 유형과 의사 결정
- 사전 구축된 도구 모음 활용
- 오류 처리 및 안전한 도구 실행