From 73e2843cf1b4dba5bdec7968fff64656d929db53 Mon Sep 17 00:00:00 2001 From: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com> Date: Thu, 9 Nov 2023 16:50:06 +0100 Subject: [PATCH] Fix deprecation warning when calling Document.from_dict() (#6267) --- haystack/preview/dataclasses/document.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/haystack/preview/dataclasses/document.py b/haystack/preview/dataclasses/document.py index 51e9a1ed7..644d12cfe 100644 --- a/haystack/preview/dataclasses/document.py +++ b/haystack/preview/dataclasses/document.py @@ -1,3 +1,4 @@ +import io import hashlib import logging from dataclasses import asdict, dataclass, field, fields @@ -145,7 +146,7 @@ class Document(metaclass=_BackwardCompatible): `dataframe` and `blob` fields are converted to their original types. """ if (dataframe := data.get("dataframe")) is not None: - data["dataframe"] = pandas.read_json(dataframe) + data["dataframe"] = pandas.read_json(io.StringIO(dataframe)) if blob := data.get("blob"): data["blob"] = ByteStream(data=bytes(blob["data"]), mime_type=blob["mime_type"]) return cls(**data)