Ferret + LangChain Integration
This directory provides LangChain-compatible tools for the Ferret web search engine.
Tools
| Tool | Description | Endpoint |
|---|---|---|
FerretSearchTool | Multi-engine web search | GET /search |
FerretResearchTool | Deep research with aggregation | POST /research |
FerretExtractTool | Extract raw content from URL | GET /extract |
FerretCrawlTool | Crawl URL for raw content | GET /crawl/v1 |
Quick Start
from langchain_ferret import FerretSearchTool, FerretResearchTool
# Search
search = FerretSearchTool()
results = search.run("latest AI news")
print(results)
# Research
research = FerretResearchTool()
answer = research.run("Impact of quantum computing on cryptography")
print(answer)
Usage with LangChain Agent
from langchain.agents import initialize_agent, AgentType
from langchain_ferret import FerretSearchTool, FerretExtractTool
from langchain_openai import ChatOpenAI
tools = [FerretSearchTool(), FerretExtractTool()]
llm = ChatOpenAI(model="gpt-4")
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION)
agent.run("Search for latest AI news and extract the content from the top result")
Requirements
pip install langchain requests
# or: pip install langchain-openai # for OpenAI-based agents
Make sure Ferret is running on http://localhost:9093:
ferret serve