A production-ready multilingual AI chatbot with RAG (Retrieval Augmented Generation) architecture. The chatbot supports 100+ languages, uses semantic search to find relevant information, and generates intelligent answers using Google Vertex AI (Gemini 2.5 Flash).
- Multilingual Support: Automatically detects and handles 100+ languages
- AI-Powered Answers: Uses Vertex AI (Gemini 2.5 Flash) to generate contextual, intelligent responses
- Semantic Search: FAISS vector database for efficient similarity search across 4000+ FAQ pairs
- RAG Architecture: Retrieves relevant context and synthesizes answers specific to user questions
- Modern UI: Clean, professional Streamlit interface inspired by ChatGPT
- Free Embeddings: Uses HuggingFace embeddings by default (no OpenAI credits required)
- Prerequisites
- Google Cloud Setup
- Local Setup
- Project Structure
- Tech Stack
- Configuration Options
- License
Before you begin, ensure you have:
- Python 3.10 or higher installed (Download Python)
- Google Cloud Account (free tier available)
- Git installed (for cloning the repository)
- Text Editor or IDE (VS Code, PyCharm, etc.)
- Go to Google Cloud Console
- Sign in with your Google account
- Click on the project dropdown at the top of the page
- Click "New Project"
- Enter a project name (e.g., "multilingual-chatbot")
- Optionally, select an organization
- Click "Create"
- Wait for the project to be created (usually takes a few seconds)
- Important: Note down your Project ID (not the project name). It will look like
multilingual-chatbot-123456
You need to enable two APIs for this project:
- In the Google Cloud Console, go to "APIs & Services" > "Library"
- Search for "Vertex AI API"
- Click on "Vertex AI API"
- Click "Enable"
- Wait for the API to be enabled (may take 1-2 minutes)
- Still in the "APIs & Services" > "Library" section
- Search for "Cloud Translation API"
- Click on "Cloud Translation API"
- Click "Enable"
- Wait for the API to be enabled
Alternative Method (Faster):
- Go to Enable Vertex AI API
- Go to Enable Translation API
A service account allows your local application to authenticate with Google Cloud services.
- In Google Cloud Console, go to "IAM & Admin" > "Service Accounts"
- Click "Create Service Account"
- Enter a service account name (e.g., "chatbot-service")
- Enter a description (optional): "Service account for multilingual chatbot"
- Click "Create and Continue"
- Grant Roles:
- Click "Select a role"
- Add these roles one by one:
- "Vertex AI User" (for Vertex AI API access)
- "Cloud Translation API User" (for Translation API access)
- Click "Continue"
- Click "Done" (you can skip the optional step of granting users access)
- In the "Service Accounts" page, find the service account you just created
- Click on the service account email
- Go to the "Keys" tab
- Click "Add Key" > "Create new key"
- Select "JSON" as the key type
- Click "Create"
- A JSON file will be downloaded automatically
- Important:
- Rename this file to
gcp-credentials.json - Move it to your project root directory (same folder as
app.py) - Never commit this file to Git (it's already in
.gitignore)
- Rename this file to
Even though you'll use the free tier, Google Cloud requires a billing account to be linked:
- Go to "Billing" in the Google Cloud Console
- Click "Link a billing account" or "Manage billing accounts"
- If you don't have a billing account:
- Click "Create billing account"
- Fill in your payment information (credit card required)
- Don't worry: You won't be charged if you stay within free tier limits
- Link your billing account to your project
- Set up billing alerts (recommended):
- Go to "Billing" > "Budgets & alerts"
- Create a budget alert for $5-10 to get notified if you exceed free tier
Free Tier Limits (per month):
- Cloud Translation API: 500,000 characters free
- Vertex AI: 15 requests per minute free
- Cloud Run: 2 million requests free (if deploying)
git clone <your-repository-url>
cd ChatbotOr if you're working with a local folder, navigate to your project directory.
Windows:
- Download Python from python.org
- During installation, check "Add Python to PATH"
- Verify installation:
Should show Python 3.10 or higher
python --version
Linux/Mac:
python3 --versionIf Python is not installed:
- Ubuntu/Debian:
sudo apt-get install python3 python3-venv python3-pip - macOS:
brew install python3
Windows:
python -m venv venv
venv\Scripts\activateLinux/Mac:
python3 -m venv venv
source venv/bin/activateYou should see (venv) in your terminal prompt, indicating the virtual environment is active.
Alternative: Use the provided installation scripts:
- Windows: Run
install.bat - Linux/Mac: Run
chmod +x install.sh && ./install.sh
pip install -r requirements.txtThis will install all required packages:
streamlit- Web UI frameworklangchain- LLM orchestrationlangchain-google-vertexai- Vertex AI integrationlangchain-community- Community integrations (FAISS, HuggingFace)google-cloud-translate- Translation APIsentence-transformers- HuggingFace embeddingsfaiss-cpu- Vector similarity searchpython-dotenv- Environment variable management
-
Create a
.envfile in the project root directory (same folder asapp.py) -
Add the following content to
.env:
# Google Cloud Configuration
GCP_PROJECT_ID=your-project-id-here
GCP_REGION=us-central1
GOOGLE_APPLICATION_CREDENTIALS=./gcp-credentials.json
# Optional: OpenAI Configuration (only if you want to use OpenAI embeddings)
# OPENAI_API_KEY=your-openai-api-key-here
# USE_OPENAI_EMBEDDINGS=false- Replace
your-project-id-herewith your actual Google Cloud Project ID (from Step 1) - Ensure
gcp-credentials.jsonis in the project root directory (from Step 4 of Google Cloud Setup) - The
GCP_REGIONcan be changed to your preferred region (e.g.,us-east1,europe-west1)
Important:
- The
.envfile is already in.gitignoreand won't be committed to Git - Never share your
.envfile orgcp-credentials.jsonpublicly
The vector store needs to be created from your FAQ data:
python setup.pyThis will:
- Load FAQs from
faqs.json - Create embeddings using HuggingFace (free) or OpenAI (if configured)
- Build and save the FAISS index to
faiss_index/directory
First run: This may take 5-10 minutes as it downloads the HuggingFace model (~90MB) and creates embeddings for all FAQs.
Subsequent runs: Much faster as the index is cached.
Verify all services are working correctly:
python test_services.pyThis will test:
- ✅ Translation service (language detection and translation)
- ✅ Vector store service (FAQ search)
- ✅ Vertex AI service (answer generation)
All tests should pass.
Start the Streamlit application:
streamlit run app.pyThe application will:
- Start a local web server
- Open your default browser automatically
- Display the chatbot interface at
http://localhost:8501
First run: You may see a spinner saying "Initializing services... This may take a minute on first run." This is normal as services load. The terminal will show progress messages.
To stop the application: Press Ctrl+C in the terminal.
Chatbot/
├── app.py # Main Streamlit application
├── translation_service.py # Google Cloud Translation API wrapper
├── vectorstore_service.py # FAISS vector search service
├── vertexai_service.py # Vertex AI (Gemini) integration
├── setup.py # Initialize vector store script
├── test_services.py # Test suite for all services
├── faqs.json # Knowledge base (4000+ Q&A pairs)
├── requirements.txt # Python dependencies
├── .env # Environment variables (create this)
├── gcp-credentials.json # GCP service account key (download from GCP)
├── .gitignore # Git ignore rules
├── install.bat # Windows installation script
├── install.sh # Linux/Mac installation script
└── README.md # This file
- Frontend: Streamlit - Python web framework
- Translation: Google Cloud Translation API - 100+ languages
- Embeddings:
- HuggingFace Sentence Transformers (default, free)
- OpenAI Embeddings (optional, paid)
- Vector Database: FAISS - Facebook AI Similarity Search
- LLM: Google Vertex AI - Gemini 2.5 Flash
- Framework: LangChain - LLM application framework
If you prefer OpenAI embeddings over HuggingFace:
- Get an OpenAI API key from platform.openai.com
- Add to
.env:OPENAI_API_KEY=sk-your-key-here USE_OPENAI_EMBEDDINGS=true
- Rebuild the vector store:
python setup.py
Note: OpenAI embeddings require credits. HuggingFace embeddings are free and work well.
Update GCP_REGION in .env:
us-central1(Iowa) - Defaultus-east1(South Carolina)europe-west1(Belgium)asia-southeast1(Singapore)
Check Vertex AI locations for available regions.
In app.py, you can modify:
k=5inget_relevant_context()- Number of FAQs to retrieve (default: 5)temperature=0.4invertexai_service.py- AI creativity (0.0-1.0)max_output_tokens=2048- Maximum answer length