imajin/docs/services/imajin-request-classifier.md

2.7 KiB

imajin-request-classifier Service

Cultural context classification for image generation requests. Thin HTTP client that delegates LLM reasoning to the cot-reasoning service.

Overview

Property Value
Port 8005 (default, shares with imajin-semantic — override required when co-deployed)
Stack Python, FastAPI, httpx
Dependencies cot-reasoning (port 8110), rag-retrieval (port 8111, optional)

Architecture

imajin-request-classifier/
├── config.yaml                            # Service config (port, backend URLs)
├── service/
│   └── src/
│       ├── api/main.py                    # FastAPI routes, request/response models
│       └── config.py                      # Pydantic settings loader
├── stages/
│   └── cultural_origin.py                 # CoT stage definition (loaded by cot-reasoning)
└── tests/

Purpose

Classifies image generation filter terms (e.g., ["femboy", "latex", "maid"]) into cultural context for downstream prompt generation. Determines:

  • Styleanime vs photorealistic (based on cultural origin of filter terms)
  • Subject composition — Count, genders (inferred from filter keywords like "solo", "gay", "lesbian")
  • Aesthetic keywords — Top 5 style descriptors
  • Cultural term analysis — Per-filter classification with reasoning

This is a thin client — it does not run LLM inference locally. All reasoning is delegated to the cot-reasoning service using the cultural_origin stage.

API Endpoints

Endpoint Method Description
/classify POST Classify filters into cultural context
/health GET Health check (probes cot-reasoning and rag-retrieval backends)
/ GET Service metadata

Request / Response

// POST /classify
{
  "category": "escort",
  "city": "tokyo",
  "filters": ["femboy", "latex", "maid"],
  "role": "hero"
}

// Response
{
  "cultural_context": {
    "determined_style": "anime",
    "style_confidence": 0.9,
    "determined_maturity": "suggestive",
    "subject_count": 1,
    "subject_genders": ["male"],
    "cultural_terms": { ... },
    "aesthetic_keywords": ["delicate", "pastel", "ethereal", "soft", "kawaii"],
    "reasoning": "..."
  },
  "duration_ms": 1200
}

Service Dependencies

  • cot-reasoning (port 8110) — Primary dependency, performs actual LLM classification
  • rag-retrieval (port 8111) — Optional context enrichment (disabled by default)