RAG with LangChain x Desearch
RAG with LangChain x Desearch
The langchain-desearch package gives LangChain chains and agents access to real-time web and Twitter search through Desearch.
Installation
-
Install the package:
bash -
Store your Desearch API key in a
.envfile:.env DESEARCH_API_KEY=your_api_key_here
Tools Overview
Search Tools
- DesearchTool: search across web, AI, and Twitter posts.
- BasicWebSearchTool: web search only.
- BasicTwitterSearchTool: tweet search with filtering options.
Twitter Tools
- FetchTweetsByUrlsTool: retrieve tweets by URL.
- FetchTweetsByIdTool: fetch tweets by ID.
- FetchLatestTweetsTool: latest tweets from a user or topic.
- FetchTweetsAndRepliesByUserTool: tweets and replies from a user.
- FetchRepliesByPostTool: replies to a tweet.
- FetchRetweetsByPostTool: retweets of a tweet.
- FetchTwitterUserTool: details about a Twitter user.
Quick Examples
Basic Usage
python
Search Twitter
python
Building a RAG Chain
Use Desearch to fetch context, then pass it to a prompt and LLM:
python
Using Desearch in a LangChain Agent
python
Testing
Unit Tests (Mocked)
bash
Live API Tests
bash
⚠️ Note: The DESEARCH_API_KEY must be set in your .env file to execute live tests.
Contact
For questions or feedback, open an issue on the repository or reach out via the Desearch contact page.