File size: 569 Bytes
242185f a5a61e2 7f9942e a5a61e2 7f9942e 66c88d2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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
@app.post("/predict")
def predict(data: InputText):
result = classifier(data.text)
return {"result": result}
@app.get("/")
def root():
return {"message": "✅ FastAPI đang chạy tại /predict"}
|