test-api / app /app.py
phamluan's picture
update
66c88d2
raw
history blame contribute delete
569 Bytes
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"}