A FastAPI application that uses AI to generate tags from content. The app supports OpenAI and local LLMs via Transformers for AI processing.
- FastAPI REST API with automatic validation
- OpenAI and Transformers integration for AI processing
- Custom validation service
- Prompt management system
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Choose and install dependencies based on your AI provider:
For OpenAI users (recommended for most users):
pip install -r requirements-openai.txtFor Transformers/Local LLM users (includes heavy ML libraries):
pip install -r requirements-transformers.txtFor all dependencies (includes everything):
pip install -r requirements.txtrequirements-openai.txt: Lightweight installation for OpenAI users. Excludes PyTorch and Transformers (~500MB savings).requirements-transformers.txt: Full installation including PyTorch and Transformers for local LLM support (~2-3GB total).requirements.txt: Complete installation with all dependencies (same as transformers version).requirements-minimal.txt: Minimal dependencies for troubleshooting installation issues.
If you encounter build errors (especially with pydantic-core), try:
# Update pip and build tools
pip install --upgrade pip setuptools wheel
# Install pydantic separately first
pip install pydantic==2.10.4 # For Python 3.13+
pip install -r requirements.txt
# Or use minimal requirements
pip install -r requirements-minimal.txtFor Python version compatibility issues, see INSTALLATION_TROUBLESHOOTING.md
For more troubleshooting options, see INSTALLATION_TROUBLESHOOTING.md
- Copy environment file and configure:
cp .env.example .env
# Edit .env with your configuration- Run the application:
# Method 1: Using the run script (recommended)
python run.py
# Method 2: Using uvicorn directly
uvicorn src.index:app --host 0.0.0.0 --port 8000 --reload
# Method 3: From project root with Python path
PYTHONPATH=. python src/index.pyCopy env.example to .env and configure:
OPENAI_API_KEY: Your OpenAI API keyOPENAI_API_BASE: API base URL (OpenAI endpoint)MODEL_NAME: Model name to use
Generate tags from content or file using AI.
Request Options:
- Text Content:
curl -X POST "http://localhost:8000/api/tags" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "content=Your text content here"- File Upload:
curl -X POST "http://localhost:8000/api/tags" \
-F "file=@your_file.txt"Accepted File Formats: txt, md, doc, docx, pdf, rtf (max 10MB)
Response:
{
"success": true,
"message": "Tags generated successfully",
"data": {
"content": "Your text content here",
"tags": ["tag1", "tag2", "tag3"],
"model_used": "gpt-4o-mini",
"source": "text", // or "file"
"filename": "file.txt", // only for file uploads
"file_size": 1024 // only for file uploads
}
}Validation Rules:
- Either
contentORfilemust be provided (not both) - Content must be 1-10000 characters
- File must be valid text format and UTF-8 encoded