File size: 532 Bytes
def09db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8ea20dc
 
def09db
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from fastapi import FastAPI
from pydantic import BaseModel
import uvicorn

app = FastAPI()


class Item(BaseModel):
    claim: str
    source: str


@app.get("/")
def greet_json():
    return {"Hello": "World!"}


def generate(item: Item):
    # return "Claim: " + item['claim']   # python
    return "Claim: " + item.claim        # huggingface space


@app.post("/generate/")
async def generate_text(item: Item):
    return {"response": generate(item)}


if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=7860)