-
Notifications
You must be signed in to change notification settings - Fork 238
Make DocumentArray compatible with FastAPI #1229
Copy link
Copy link
Closed
Description
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 docbut 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 docReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done