Spaces:
Runtime error
Runtime error
metadata
title: Gohan Product Recommendation API
emoji: 🍚
colorFrom: yellow
colorTo: yellow
sdk: docker
sdk_version: 0.2.0
app_file: app.py
pinned: false
Gohan FastAPI
This is a FastAPI-based product recommendation API deployed on Hugging Face Spaces.
Endpoints
GET /- Root endpoint with API informationGET /status- Health check and model statusPOST /predict- Main prediction endpoint with topK parameterPOST /predict_simple- Simple prediction endpoint
Usage
Check API Status
curl "https://tabito123-gohan-api-light.hf.space/status"
Make Predictions
curl -X POST "https://tabito123-gohan-api-light.hf.space/predict" \
-H "Content-Type: application/json" \
-d '{"company_data_json": "{\"INDUSTRY\": \"IT\"}", "topK": 10}'
Model Loading
The API uses FastAPI's lifespan events to load models only once during startup, providing efficient cold start handling.
Required Model Files
model/gohan/epoch_*.pt(PyTorch model)model/gohan/*.json(encoder files)model/gohan/gohan_pm.csv(product master data)
API Response Format
{
"status": "success",
"model": "gohan",
"recommendations": [
{
"category_id": 123,
"category_name": "栄養豊富な雑穀米",
"score": 0.95
}
],
"metadata": {
"model_version": "gohan_cid_v1.0",
"total_categories": 30,
"requested_k": 10
}
}
Cold Start Handling
The API automatically handles cold starts by:
- Loading models during startup
- Providing
/statusendpoint to check readiness - Returning appropriate HTTP status codes during loading
- Graceful error handling for unready states