A FastAPI-based chatbot application that integrates with Google's Vertex AI to provide conversational AI capabilities.
This project provides a RESTful API for interacting with Google's Gemini AI model through Vertex AI. It's built with FastAPI and designed to be containerized using Docker for easy deployment.
- FastAPI Framework: Modern, fast web framework for building APIs
- Google Vertex AI Integration: Leverages Gemini 2.5 Flash model for AI responses
- Docker Support: Containerized application for consistent deployment
- Conversation Management: Supports message history for contextual conversations
- RESTful API: Clean API structure with versioned endpoints
- Python 3.14+
- Google Cloud Project with Vertex AI API enabled
- Service Account credentials with appropriate permissions
- Docker (optional, for containerized deployment)
- Clone the repository:
git clone <repository-url>
cd vertexai-chatbot- Install dependencies:
pip install -r requirements.txt-
Configure Google Cloud credentials:
- Place your service account JSON file in
app/credentials/credential.json - Ensure the service account has Vertex AI permissions
- Place your service account JSON file in
-
Test the application:
fastapi dev main.py- Run the application:
uvicorn app.main:app --host 0.0.0.0 --port 8000- Build the Docker image:
docker build -t vertexai-chatbot .- Run the container:
docker run -p 8000:8000 vertexai-chatbotEndpoint: POST /api/v1/chatbot/message
Request Body:
{
"message": "Hello, how can you help me?",
"history": [
{
"author_id": 0,
"content": "AI-generated response"
},
{
"author_id": 1,
"content": "Hello, My name is Ever"
}
]
}Response:
{
"message": "AI-generated response here",
"status": true
}