SQL-Agent is a Python-based tool designed to perform similarity searches on a database of documents containing frequently asked questions (FAQs) or similar content. By retrieving relevant documents, SQL-Agent reduces hallucinations and improves the accuracy of AI-generated responses. The tool is ideal for enhancing the reliability of language model outputs by providing contextually relevant information from trusted sources.
- Similarity Search: Efficiently searches for documents with questions similar to the input query.
- Reduced Hallucinations: Minimizes errors in AI-generated responses by providing factual references.
- Seamless Database Integration: Connects to PostgreSQL databases for storing and retrieving documents.
- Customizable: Easily adaptable to different datasets and configurations.
The following Python libraries are required to run SQL-Agent:
python-dotenv
: For managing environment variables.langchain_openai
: Integration with OpenAI's language models.langchain_community
: Community-driven tools for LangChain.langchain_core
: Core LangChain functionalities.langchain_experimental
: Experimental features for LangChain.psycopg2-binary
: PostgreSQL database adapter for Python.google_search_results
: API for Google Search integration.
To install the dependencies, run:
pip install -r requirements.txt
- Clone the repository:
git clone https://github.com/PragalvhaSharma/SQL-Agent.git
- Navigate to the project directory:
cd SQL-Agent
- Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
- Install dependencies:
pip install -r requirements.txt
-
Environment Setup: Create a
.env
file in the project directory with the following variables:OPENAI_API_KEY=your_openai_api_key DATABASE_URL=your_postgresql_database_url GOOGLE_API_KEY=your_google_api_key GOOGLE_CX=your_google_custom_search_engine_id
-
Database Configuration: Ensure your PostgreSQL database is set up and populated with the required documents. Use the provided SQL schema (if available) to structure your database correctly.
-
Running the Script: Execute the main Python script to start the similarity search:
python main.py
-
Query Example: Input a question or query, and the system will retrieve similar documents from the database to enhance the response quality.
Contributions are welcome! If you have ideas, suggestions, or bug fixes, please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or support, contact Pragalvha Sharma.
Special thanks to the LangChain community and contributors for providing tools that made this project possible.