File tree Expand file tree Collapse file tree
Open diff view settings
docs/user_guide/sending/api Expand file tree Collapse file tree
Open diff view settings
Original file line number Diff line number Diff line change @@ -95,13 +95,21 @@ Image(
9595) # fails validation because it does not have enough dimensions
9696```
9797
98+ ## Use DocList with FastAPI
9899
99- Further, you can send and receive lists of documents represented as a ` DocList ` object:
100+ Further, you can send and receive lists of documents represented as a ` DocList ` object.
100101
101- !!! note
102- Currently, ` FastAPI ` receives ` DocList ` objects as lists, so you have to construct a DocList inside the function.
103- Also, if you want to return a ` DocList ` object, first you have to convert it to a list.
104- (Shown in the example below)
102+ To do that, you need to receive a list of documents (` List[TextDoc] ` ) in your FastAPI function, and then convert it to a ` DocList ` object.
103+ To return a ` DocList ` object, similarly, you need to convert it to a list first.
104+
105+ !!! note "Why is there no native support for ` DocList ` ?"
106+ We would love to natively support ` DocList ` in FastAPI, but it's not possible at the moment due to some behaviour
107+ stemming from Pydantic. This should be resolved once [ Pydantic v2] ( https://docs.pydantic.dev/latest/blog/pydantic-v2/ ) is released.
108+
109+ If you are curious about the root cause of this, you can check out the following issues:
110+ - [Pydantic issue #1457](https://github.com/pydantic/pydantic/issues/1457)
111+ - [Should be resolved in Pydantic v2 (#4161)](https://github.com/pydantic/pydantic/issues/4161)
112+ - [DocArray needs the above (#1521)](https://github.com/docarray/docarray/issues/1521)
105113
106114``` python
107115from typing import List
You can’t perform that action at this time.
0 commit comments