hello-ram commited on
Commit
f3c61d6
·
verified ·
1 Parent(s): 08ef677

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -18,9 +18,29 @@ model = AutoModelForCausalLM.from_pretrained(
18
  device_map="auto"
19
  )
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  class InputText(BaseModel):
22
  text: str
23
 
 
24
  @app.post("/generate")
25
  async def generate_text(data: InputText):
26
  inputs = tokenizer(data.text, return_tensors="pt").to(model.device)
 
18
  device_map="auto"
19
  )
20
 
21
+ # ---------- ROUTES -------------
22
+
23
+ @app.get("/")
24
+ async def root():
25
+ return {
26
+ "message": "🚀 FastAPI MPT Model Running on Hugging Face Spaces",
27
+ "endpoints": ["/", "/status", "/generate"]
28
+ }
29
+
30
+ @app.get("/status")
31
+ async def status():
32
+ return {
33
+ "status": "ok",
34
+ "model": MODEL_REPO,
35
+ "device": str(model.device),
36
+ "torch_dtype": str(model.dtype)
37
+ }
38
+
39
+
40
  class InputText(BaseModel):
41
  text: str
42
 
43
+
44
  @app.post("/generate")
45
  async def generate_text(data: InputText):
46
  inputs = tokenizer(data.text, return_tensors="pt").to(model.device)