Skip to content

Commit

Permalink
Fix deprecation warning when calling Document.from_dict() (#6267)
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza authored Nov 9, 2023
1 parent f95937b commit 73e2843
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion haystack/preview/dataclasses/document.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import io
import hashlib
import logging
from dataclasses import asdict, dataclass, field, fields
Expand Down Expand Up @@ -145,7 +146,7 @@ def from_dict(cls, data: Dict[str, Any]) -> "Document":
`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)
Expand Down

0 comments on commit 73e2843

Please sign in to comment.