nlql / webservice / main.py
main.py
Raw
from fastapi import FastAPI
from pydantic import BaseModel
from typing import Union

app = FastAPI()

class QueryItem(BaseModel):
    id: Union [int, None] = None
    question: str
    

@app.put("/test-api/{db_id}")
async def read_query(db_id, query: QueryItem):
    
    ### change the dummy function to the function we need
    
    return await dummy(db_id, query)


async def dummy(db_id, query: QueryItem):
    return {"message": {
        "db_id": db_id,
        "id": query.id,
        "question": query.question
    }}