mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-08-29 19:06:21 +00:00
Fix deprecation warning when calling Document.from_dict() (#6267)
This commit is contained in:
parent
f95937b0ce
commit
73e2843cf1
@ -1,3 +1,4 @@
|
|||||||
|
import io
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
from dataclasses import asdict, dataclass, field, fields
|
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.
|
`dataframe` and `blob` fields are converted to their original types.
|
||||||
"""
|
"""
|
||||||
if (dataframe := data.get("dataframe")) is not None:
|
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"):
|
if blob := data.get("blob"):
|
||||||
data["blob"] = ByteStream(data=bytes(blob["data"]), mime_type=blob["mime_type"])
|
data["blob"] = ByteStream(data=bytes(blob["data"]), mime_type=blob["mime_type"])
|
||||||
return cls(**data)
|
return cls(**data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user