| import os | |
| os.environ["HF_HOME"] = "/tmp" # ✅ Tránh lỗi ghi vào /.cache | |
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| from transformers import pipeline | |
| app = FastAPI() | |
| model_id = "phamluan/ai-auto-excute-script" | |
| classifier = pipeline("text-classification", model=model_id, tokenizer=model_id) | |
| class InputText(BaseModel): | |
| text: str | |
| def predict(data: InputText): | |
| result = classifier(data.text) | |
| return {"result": result} | |
| def root(): | |
| return {"message": "✅ FastAPI đang chạy tại /predict"} | |