mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
* rebuilding executor * removing langchain * Making all tests good * fixing types and adding ability for nor using system prompts * improving types * pleasing the types gods * pleasing the types gods * fixing parser, tools and executor * making sure all tests pass * final pass * fixing type * Updating Docs * preparing to cut new version
39 lines
1.4 KiB
Markdown
39 lines
1.4 KiB
Markdown
---
|
||
title: Using LangChain Tools
|
||
description: Learn how to integrate LangChain tools with CrewAI agents to enhance search-based queries and more.
|
||
---
|
||
|
||
## Using LangChain Tools
|
||
!!! info "LangChain Integration"
|
||
CrewAI seamlessly integrates with LangChain’s comprehensive [list of tools](https://python.langchain.com/docs/integrations/tools/), all of which can be used with crewAI.
|
||
|
||
```python
|
||
import os
|
||
from crewai import Agent
|
||
from langchain.agents import Tool
|
||
from langchain.utilities import GoogleSerperAPIWrapper
|
||
|
||
# Setup API keys
|
||
os.environ["SERPER_API_KEY"] = "Your Key"
|
||
|
||
search = GoogleSerperAPIWrapper()
|
||
|
||
# Create and assign the search tool to an agent
|
||
serper_tool = Tool(
|
||
name="Intermediate Answer",
|
||
func=search.run,
|
||
description="Useful for search-based queries",
|
||
)
|
||
|
||
agent = Agent(
|
||
role='Research Analyst',
|
||
goal='Provide up-to-date market analysis',
|
||
backstory='An expert analyst with a keen eye for market trends.',
|
||
tools=[serper_tool]
|
||
)
|
||
|
||
# rest of the code ...
|
||
```
|
||
|
||
## Conclusion
|
||
Tools are pivotal in extending the capabilities of CrewAI agents, enabling them to undertake a broad spectrum of tasks and collaborate effectively. When building solutions with CrewAI, leverage both custom and existing tools to empower your agents and enhance the AI ecosystem. Consider utilizing error handling, caching mechanisms, and the flexibility of tool arguments to optimize your agents' performance and capabilities. |