phamluan commited on
Commit
7f9942e
·
1 Parent(s): a5a61e2

first push

Browse files
Files changed (2) hide show
  1. app/__pycache__/app.cpython-310.pyc +0 -0
  2. app/app.py +14 -3
app/__pycache__/app.cpython-310.pyc ADDED
Binary file (799 Bytes). View file
 
app/app.py CHANGED
@@ -1,7 +1,18 @@
1
  from fastapi import FastAPI
 
 
2
 
3
  app = FastAPI()
4
 
5
- @app.get("/")
6
- def greet_json():
7
- return {"Hello": "World!"}
 
 
 
 
 
 
 
 
 
 
1
  from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ from transformers import pipeline
4
 
5
  app = FastAPI()
6
 
7
+ # Pipeline với model của bạn
8
+ model_id = "phamluan/ai-auto-excute-script"
9
+ classifier = pipeline("text-classification", model=model_id, tokenizer=model_id)
10
+
11
+ class InputText(BaseModel):
12
+ text: str
13
+
14
+ @app.post("/predict")
15
+ def predict(data: InputText):
16
+ result = classifier(data.text)
17
+ return {"result": result}
18
+