Flask API Only - Required Files List
This document lists all files needed for a Flask API-only deployment (no Gradio UI).
π Essential Files (Required)
Core Application Files
Research_AI_Assistant/
βββ flask_api_standalone.py # Main Flask application (REQUIRED)
βββ Dockerfile.flask # Dockerfile for Flask deployment (rename to Dockerfile)
βββ README_FLASK_API.md # README with HF Spaces frontmatter (rename to README.md)
βββ requirements.txt # Python dependencies (REQUIRED)
Source Code Directory (src/)
Research_AI_Assistant/src/
βββ __init__.py # Package initialization
βββ config.py # Configuration settings
βββ llm_router.py # LLM routing (local GPU models)
βββ local_model_loader.py # GPU model loader (NEW - for local inference)
βββ orchestrator_engine.py # Main orchestrator
βββ context_manager.py # Context management
βββ models_config.py # Model configurations
βββ agents/
β βββ __init__.py
β βββ intent_agent.py # Intent recognition agent
β βββ synthesis_agent.py # Response synthesis agent
β βββ safety_agent.py # Safety checking agent
β βββ skills_identification_agent.py # Skills identification agent
βββ database.py # Database management (if used)
Configuration Files (Optional but Recommended)
Research_AI_Assistant/
βββ .env # Environment variables (optional, use HF Secrets instead)
βββ .gitignore # Git ignore rules
π¦ File Descriptions
1. flask_api_standalone.py β REQUIRED
- Purpose: Main Flask application entry point
- Contains: API endpoints, orchestrator initialization, request handling
- Key Features:
- Local GPU model loading
- Async orchestrator support
- Health checks
- Error handling
2. Dockerfile.flask β Dockerfile β REQUIRED
- Purpose: Container configuration
- Action: Rename to
Dockerfilewhen deploying - Includes: Python 3.10, system dependencies, health checks
3. README_FLASK_API.md β README.md β REQUIRED
- Purpose: HF Spaces configuration and API documentation
- Action: Rename to
README.mdwhen deploying - Contains: Frontmatter with
sdk: docker, API endpoints, usage examples
4. requirements.txt β REQUIRED
- Purpose: Python package dependencies
- Includes: Flask, transformers, torch (GPU), sentence-transformers, etc.
5. src/local_model_loader.py β REQUIRED (NEW)
- Purpose: Loads models locally on GPU
- Features: GPU detection, model caching, FP16 optimization
6. src/llm_router.py β REQUIRED (UPDATED)
- Purpose: Routes inference requests
- Features: Tries local models first, falls back to HF API
7. src/orchestrator_engine.py β REQUIRED
- Purpose: Main AI orchestration engine
- Contains: Agent coordination, request processing
8. src/context_manager.py β REQUIRED
- Purpose: Manages conversation context
- Features: Session management, context retrieval
9. src/agents/*.py β REQUIRED
- Purpose: Individual AI agents
- Agents: Intent, Synthesis, Safety, Skills Identification
10. src/config.py β REQUIRED
- Purpose: Application configuration
- Settings: MAX_WORKERS=4, model paths, etc.
β Files NOT Needed (Gradio/UI Related)
These files can be excluded from Flask API deployment:
Research_AI_Assistant/
βββ app.py # Gradio UI (NOT NEEDED)
βββ main.py # Gradio + Flask launcher (NOT NEEDED)
βββ flask_api.py # Flask API (use standalone instead)
βββ Dockerfile # Main Dockerfile (use Dockerfile.flask)
βββ Dockerfile.hf # Alternative Dockerfile (NOT NEEDED)
βββ README.md # Main README (use README_FLASK_API.md)
βββ All .md files except this one # Documentation (optional)
π Quick Deployment Checklist
Step 1: Prepare Files
# In your Flask API Space directory:
cp Dockerfile.flask Dockerfile
cp README_FLASK_API.md README.md
Step 2: Verify Structure
Your Space/
βββ Dockerfile # β
Renamed from Dockerfile.flask
βββ README.md # β
Renamed from README_FLASK_API.md
βββ flask_api_standalone.py # β
Main Flask app
βββ requirements.txt # β
Dependencies
βββ src/ # β
All source files
βββ __init__.py
βββ config.py
βββ llm_router.py
βββ local_model_loader.py
βββ orchestrator_engine.py
βββ context_manager.py
βββ models_config.py
βββ agents/
βββ __init__.py
βββ intent_agent.py
βββ synthesis_agent.py
βββ safety_agent.py
βββ skills_identification_agent.py
Step 3: Set Environment Variables
In HF Spaces Settings β Secrets:
HF_TOKEN- Your Hugging Face token
Step 4: Deploy
- Select NVIDIA T4 Medium GPU
- Set SDK: docker
- Deploy
π File Size Considerations
Minimal Deployment (Essential Only)
- Core files: ~50 KB
- Source code: ~500 KB
- Total: ~550 KB code
With Models (First Load)
- Code: ~550 KB
- Models (downloaded on first run): ~14-16 GB
- Total: ~14-16 GB (first build)
Subsequent Builds
- Models cached by HF Spaces
- Code only: ~550 KB
π Verification
After deployment, verify these files exist:
# Check main files
ls -la Dockerfile README.md flask_api_standalone.py requirements.txt
# Check source directory
ls -la src/
ls -la src/agents/
# Verify key components
grep -r "local_model_loader" src/llm_router.py
grep -r "MAX_WORKERS" src/config.py
π Summary
Minimum Required Files:
flask_api_standalone.pyDockerfile(from Dockerfile.flask)README.md(from README_FLASK_API.md)requirements.txt- All files in
src/directory
Total: ~15-20 files (excluding documentation)
Note: This is a minimal deployment. All Gradio UI files, documentation, and test files are optional and can be excluded to reduce repository size.