Context
Atm FastAPI is working with BaseDocument. But we need to make it work for DocumentArray.
this is currently working
class Mmdoc(BaseDocument):
img: ImageDoc
text: TextDoc
title: str
input_doc = Mmdoc(
img=ImageDoc(tensor=np.zeros((3, 224, 224))), text=TextDoc(), title='hello'
)
app = FastAPI()
@app.post("/doc/", response_model=Mmdoc, response_class=DocumentResponse)
async def create_item(doc: Mmdoc):
return doc
but we need to extend it to
class Mmdoc(BaseDocument):
img: ImageDoc
text: TextDoc
title: str
da = DocumentArray[Mmdoc]([Mmdoc(
img=ImageDoc(tensor=np.zeros((3, 224, 224))), text=TextDoc(), title='hello'
)])
app = FastAPI()
@app.post("/doc/", response_model=DocumentArray[Mmdoc], response_class=DocumentArrayResponse)
async def create_item(da: DocumentArray[Mmdoc]):
return doc
Context
Atm FastAPI is working with BaseDocument. But we need to make it work for DocumentArray.
this is currently working
but we need to extend it to