Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -2,16 +2,20 @@ from fastapi import FastAPI
|
|
| 2 |
from app import predict
|
| 3 |
import os
|
| 4 |
from huggingface_hub import login
|
|
|
|
| 5 |
|
| 6 |
os.environ['HF_HOME'] = '/hug/cache/'
|
| 7 |
os.environ['TRANSFORMERS_CACHE'] = '/blabla/cache/'
|
| 8 |
|
| 9 |
app = FastAPI()
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
@app.get("/")
|
| 12 |
async def root():
|
| 13 |
return {"Code Review Automation":"Version 1.0 'First Draft'"}
|
| 14 |
|
| 15 |
@app.post("/AutomateReview/")
|
| 16 |
-
async def predict(
|
| 17 |
-
return predict(
|
|
|
|
| 2 |
from app import predict
|
| 3 |
import os
|
| 4 |
from huggingface_hub import login
|
| 5 |
+
from pydantic import BaseModel
|
| 6 |
|
| 7 |
os.environ['HF_HOME'] = '/hug/cache/'
|
| 8 |
os.environ['TRANSFORMERS_CACHE'] = '/blabla/cache/'
|
| 9 |
|
| 10 |
app = FastAPI()
|
| 11 |
|
| 12 |
+
class Item(BaseModel):
|
| 13 |
+
code: str
|
| 14 |
+
|
| 15 |
@app.get("/")
|
| 16 |
async def root():
|
| 17 |
return {"Code Review Automation":"Version 1.0 'First Draft'"}
|
| 18 |
|
| 19 |
@app.post("/AutomateReview/")
|
| 20 |
+
async def predict(item: Item):
|
| 21 |
+
return predict(item.dict())
|