A Streamlit-powered application leveraging LangChain, OpenAI GPT, and MongoDB to dynamically convert natural language queries into MongoDB commands.
- Natural Language Query Processing: Converts user input into optimized MongoDB queries using GPT models.
- LangChain Integration: Uses the LangGraph Agent for enhanced multi-step query workflows and decision-making.
- User-Friendly Interface: Built with Streamlit for a seamless and interactive user experience.
- Robust Backend: Handles dynamic query execution and ensures accurate database responses.
- Dockerized Deployment: Easy-to-use containerized setup for consistent and scalable deployment.
The system comprises the following components:
-
Frontend:
- Streamlit App: A lightweight interface for users to input natural language queries.
-
Backend:
- LangChain with OpenAI GPT: Converts natural language into MongoDB queries.
- Database Handler: Executes the queries and retrieves results from MongoDB.
-
Database:
- MongoDB: Stores data and supports complex NoSQL queries.
-
Deployment:
- Dockerized Environment: Ensures portability and consistency across systems.
The Agent's workflow:
- Docker installed on your system.
- A running instance of MongoDB.
- OpenAI API Key for GPT access.
- Clone the Repository
git clone https://github.com/username/NL2MongoDB.git cd NL2MongoDB - Configure Environment Variables Create a .env file in the root directory containing
OPENAI_API_KEY=
MONGO_URI=
PROMPT_PATH=
AGENT_PROMPT_PATH=
LOG_FILE=
DATABASE_NAME=
COLLECTION_NAME=
- Build and Run the Docker Container
docker build -t nl2mongodb . docker run -p 8080:8080 nl2mongodb - Access the Application Open your browser and navigate to http://localhost:8080
- Input a natural language query into the Streamlit app.
- Review the generated MongoDB query.
- View results dynamically fetched from the MongoDB database.
- Programming Language: Python
- Framework: Streamlit
- AI Model: GPT-4o (via OpenAI API)
- Integration: LangChain (LangGraph Agent,and LLM integration)
- Database: MongoDB
- Containerization: Docker
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Commit your changes (
git commit -m 'Add feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.






