This application is built using FastAPI and enables users to connect to both SQL and NoSQL databases, perform queries, and interact through a chat interface. It leverages LangFlow components for database interactions and response generation.
Before starting, ensure the following are in place:
- Python Version: 3.10 or higher
- Docker: Make sure Docker is installed and running on your server machine
- Docker Compose: Ensure Docker Compose is installed for building and running the containers
Start by cloning this repository to your server using the following command:
git clone https://github.com/MuhammadAdil-Developer/langflow-chatbot
cd langflow-chatdocker-compose up --buildThis command will:
- Build and start container
- Show real-time logs in your terminal
- Useful for initial testing and debugging
docker-compose up -d --buildThis will:
- Build and start container in the background
- Allow continued use of your terminal
- Containers run in the background
View container status:
docker-compose psCheck logs in detached mode:
docker-compose logs -fStop containers:
docker-compose stopRemove containers (preserves data):
docker-compose downRestart services:
docker-compose restartAfter the server starts, you can access the application through:
- Main Application:
http://your-seerver-ip:8080/chat - API Documentation:
http://your-seerver-ip/docs
- Endpoint:
POST /connect-db - Description: Connects to a specified SQL or NoSQL database
- Request Body:
{
"question": "Your question here"
}- Endpoint:
POST /chat - Description: Sends a question to the connected database and retrieves a response
- Request Body:
{
"question": "Your question here",
"db_name": "Database name",
"database_uri": "Database URI",
"collection_name": "Collection name",
"db_type": "sql or nosql"
}- Endpoint:
GET /chat - Description: Retrieves the chat history for a user session
The application includes error handling for various scenarios, including:
- Invalid database URIs
- Connection failures
- Query execution errors
- Add support for additional database types
- Improve chat interface with more conversational AI features
- Implement authentication for secure API access
If you encounter any issues during setup or while running the project, check the following:
- Ensure Docker is properly installed and running
- Check for any missing dependencies
- Verify network connectivity for database connections
- Ensure required ports are available