Skip to content

🤖 AI-powered tag generation from text and files. Supports OpenAI and HuggingFace models. FastAPI-based REST API with intelligent content analysis.

License

Notifications You must be signed in to change notification settings

itsmattius/TagGen-AI

Repository files navigation

TagGen AI

A FastAPI application that uses AI to generate tags from content. The app supports OpenAI and local LLMs via Transformers for AI processing.

Features

  • FastAPI REST API with automatic validation
  • OpenAI and Transformers integration for AI processing
  • Custom validation service
  • Prompt management system

Setup

  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Choose and install dependencies based on your AI provider:

For OpenAI users (recommended for most users):

pip install -r requirements-openai.txt

For Transformers/Local LLM users (includes heavy ML libraries):

pip install -r requirements-transformers.txt

For all dependencies (includes everything):

pip install -r requirements.txt

Requirements Files Explained

  • requirements-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.txt

For Python version compatibility issues, see INSTALLATION_TROUBLESHOOTING.md

For more troubleshooting options, see INSTALLATION_TROUBLESHOOTING.md

  1. Copy environment file and configure:
cp .env.example .env
# Edit .env with your configuration
  1. 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.py

Environment Variables

Copy env.example to .env and configure:

  • OPENAI_API_KEY: Your OpenAI API key
  • OPENAI_API_BASE: API base URL (OpenAI endpoint)
  • MODEL_NAME: Model name to use

API Endpoints

POST /api/tags

Generate tags from content or file using AI.

Request Options:

  1. Text Content:
curl -X POST "http://localhost:8000/api/tags" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "content=Your text content here"
  1. 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 content OR file must be provided (not both)
  • Content must be 1-10000 characters
  • File must be valid text format and UTF-8 encoded

About

🤖 AI-powered tag generation from text and files. Supports OpenAI and HuggingFace models. FastAPI-based REST API with intelligent content analysis.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages