A Flask web application that serves as a client interface for interacting with AI language model APIs. Provides both a user-friendly web interface and RESTful API endpoints for programmatic access.
This application is a Flask-based web client that provides an interface for interacting with AI language model APIs. It consists of two main components working together to deliver a seamless user experience.
- Backend: Flask (Python 3.10+)
- Frontend: HTML5 with Tailwind CSS
- Container: Docker/Podman support
- Orchestration: Kubernetes with Istio service mesh compatibility
- API Protocol: OpenAI-compatible format
The application follows a simple proxy architecture:
-
Web Interface (
templates/index.html)- Single-page application built with Tailwind CSS
- Provides real-time question/answer interface
- Responsive design for multiple device types
-
API Proxy (
app.py)- Flask server that proxies requests to external AI services
- Exposes
/api/completionsendpoint - Forwards requests to AI service's
/v1/completionsendpoint - Handles OpenAI-compatible API format
User → Web Interface → Flask App → AI Service (OpenAI-compatible)
↓
API Response ← AI Service Response
- Health Checks: Built-in liveness and readiness probes
- Resource Management: Configurable CPU and memory limits
- Service Mesh Ready: Istio compatible with traffic management
- Environment Configuration: Flexible AI service endpoint configuration
- Python 3.10 or higher
- pip package manager
-
Create and activate virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment
export ADDRESS="http://127.0.0.1:8000" # Replace with your AI service URL
-
Run the application
python app.py
The application will be available at http://localhost:5000
- Podman installed and configured
-
Build the container image
podman build -t ilab-client . -
Run the container
export ADDRESS="http://your-ai-service:8000" # Configure your AI service URL podman run -d -p 5000:5000 -e ADDRESS="$ADDRESS" --name ilab-client ilab-client
-
Access the application Open your browser to
http://localhost:5000 -
Stop and remove container
podman stop ilab-client podman rm ilab-client
This section explains how to deploy the application to a Kubernetes cluster using the provided manifest files.
- Kubernetes cluster with
kubectlconfigured - The
instructlabservice running on port 8080 in the target namespace
-
Create the namespace
kubectl create namespace ilab-chat
-
Deploy the application manifests
# Deploy the application kubectl apply -f manifests/deployment.yaml # Deploy the service kubectl apply -f manifests/service.yaml
-
Verify the deployment
# Check pod status kubectl get pods -n ilab-chat # Check service status kubectl get services -n ilab-chat # Check deployment details kubectl describe deployment ilab-client -n ilab-chat
-
Access the application
# Get the external IP (for LoadBalancer service) kubectl get service ilab-client-service -n ilab-chat # If using port-forward for testing kubectl port-forward service/ilab-client-service 5000:5000 -n ilab-chat
instructlab to be available on port 8080 within the same namespace (ilab-chat). This service should provide the AI language model API that the client will proxy requests to.
The deployment configuration automatically sets the ADDRESS environment variable to http://instructlab:8000 as seen in the deployment manifest.
-
manifests/deployment.yaml:- Defines the application deployment with 1 replica
- Configures resource limits (256Mi memory, 200m CPU)
- Sets up health checks (liveness and readiness probes)
- Points to the
instructlab:8000service
-
manifests/service.yaml:- Creates a LoadBalancer service
- Exposes the application on port 5000
- Provides external access to the web interface
If pods are not starting or are in CrashLoopBackOff:
-
Check pod logs
kubectl logs deployment/ilab-client -n ilab-chat
-
Verify instructlab service exists
kubectl get service instructlab -n ilab-chat
-
Test connectivity to instructlab service
kubectl run debug --rm -it --image=curlimages/curl -n ilab-chat -- sh # Inside the pod: curl http://instructlab:8000/v1/completions
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Maintainer: Rafael Zago
Repository: https://github.com/rafaelvzago/ilab-client
Issues: https://github.com/rafaelvzago/ilab-client/issues
