CoolFace
Apppublic

sayshara/simple-ascii-art-txtai

sourceHugging Faceapache-2.0updated 4mo agoView on Hugging Face
0likes
App README

Simple ASCII Art txtai API

CPU-only Docker Space serving a prebuilt txtai embeddings index for semantic search over `PinkPixel/ASCII-Art`. It uses minimal runtime dependencies: CPU-only PyTorch, txtai, FastAPI, and Uvicorn.

The Space is designed to use a persistent bucket mounted at /data. The Granite embedding model is stored as regular files under /data/models/granite-embedding-english-r2, so after the first download, restarts should reuse the cached model instead of downloading it again.

The index is small enough to include directly in the Space repo:

  • —Index directory: txtai_ascii_art_embeddings/
  • —Embedding model: ibm-granite/granite-embedding-english-r2
  • —Rows: 1,221
  • —Indexed field: text
  • —Returned metadata: text, ascii_art

Endpoints

  • —GET /health — status and index metadata
  • —GET /search?query=a cute kitten&limit=5 — semantic search
  • —POST /search with {"query": "a cute kitten", "limit": 5} — semantic search
  • —GET /metadata/{id} — raw metadata row
  • —GET /docs — OpenAPI UI

Example:

bash
curl "https://<space-subdomain>.hf.space/search?query=a%20cute%20kitten&limit=3"

Why a custom FastAPI wrapper?

The stock txtai API can serve an embeddings index with CONFIG=config.yml uvicorn txtai.api:app, but this dataset stores the ASCII art in metadata.jsonl sidecar records. app.py loads the txtai index and enriches search results with the matching ASCII art, which is more convenient for agents and downstream apps.

config.yml is included for reference if you want to run the stock txtai API.