|
|
import os |
|
|
os.environ["HF_HOME"] = "/tmp" |
|
|
|
|
|
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"} |
|
|
|