A Retrieval-Augmented Generation (RAG) chatbot built using TavilySearch and LangChain, designed to respond to user queries with precise, well-structured answers in Markdown format. The chatbot leverages the TavilySearch tool to retrieve relevant web-based information and presents it via a Streamlit application.
- Integration with TavilySearch: Uses TavilySearchResults for retrieving web-based data to enhance responses.
- Markdown Formatting: Outputs responses in clean Markdown format with headings, lists, tables, and code blocks for better readability.
- Streamlit Interface: Provides a user-friendly web interface for asking queries and viewing responses.
- Tool-Assisted Responses: Employs LangChain’s tool-calling agents for dynamic query resolution.
- Python
- Streamlit: For creating the web-based user interface.
- LangChain: Framework for building tool-augmented chatbots.
- TavilySearchResults: Tool for retrieving web search results.
- ChatGroq: AI model for generating conversational responses.
- dotenv: For managing environment variables.
Follow these steps to set up the project locally:
-
Clone the repository:
git clone https://github.com/Osama-Abo-Bakr/RAG-Chatbot-using-TavilySearch.git cd RAG-Chatbot-using-TavilySearch
-
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a
.env
file and set up your environment variables. For example:OPENAI_API_KEY=your_openai_api_key TAVILY_API_KEY=your_tavily_api_key
-
Run the application:
streamlit run app.py
-
Open your web browser and navigate to
http://localhost:8501
. -
Enter your query in the chat input box and receive well-structured responses.
This function:
- Integrates the TavilySearchResults tool for web searches.
- Uses LangChain to create a tool-calling agent with a custom prompt.
- Executes the agent to generate responses based on user input.
This function:
- Loads environment variables.
- Configures the Streamlit interface.
- Handles user queries and displays both user input and the chatbot’s responses.
-
Input:
What are the benefits of machine learning?
-
Output:
# Benefits of Machine Learning - Automates repetitive tasks. - Enhances decision-making processes. - Improves efficiency in various industries.
Contributions are welcome! Please fork the repository and create a pull request for any improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or support, feel free to reach out:
- GitHub: Osama-Abo-Bakr
Enjoy building and exploring with the RAG-Chatbot!