Find answers from the community

Updated 3 months ago

I have a FastAPI app running on a remote

I have a FastAPI app running on a remote server (with a better GPU than my personal computer) that returns a pydantic model of the form:
Plain Text
class PipelineResults(BaseModel):
    nodes: List[BaseNode]


The API returns a serialized form of PipelineResults, and in my PC script:
Plain Text
response = requests.post(pipeline_url, json=json_data.model_dump(), headers=headers) # response = serialized PipelineResults
result = PipelineResults.model_validate(response.json()) # raises err

I get the error:
TypeError: Can't instantiate abstract class BaseNode with abstract methods get_content, get_metadata_str, get_type, hash, set_content

Which I assume is because the BaseNode class doesn't have a method to deserialize the dict. Is there any solution for this?
Thanks all, have loved using llamaindex so far πŸ™‚
L
j
3 comments
Yea, you'll need to either use the actualy type (TextNode or similar), or implement some custom serialization logic in your pydantic class to properly load the correct class
Serialization with pydantic and base classes is kind of a nightmare lol
Thanks! I ended up typing it as TextNode and it worked out.
Add a reply
Sign up and join the conversation on Discord