File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -571,16 +571,15 @@ def _doc_from_bytes(
571
571
) -> BaseDoc :
572
572
schema = self .out_schema if out else self ._schema
573
573
schema_cls = cast (Type [BaseDoc ], schema )
574
- pb = DocProto .FromString (data )
574
+ pb = DocProto .FromString (
575
+ data
576
+ ) # I cannot reconstruct directly the DA object because it may fail at validation because embedding may not be Optional
575
577
for k , v in reconstruct_embeddings .items ():
576
- nd_proto = NdArrayProto ()
577
- np_array = np .array (v )
578
- nd_proto .dense .buffer = np_array .tobytes ()
579
- nd_proto .dense .ClearField ('shape' )
580
- nd_proto .dense .shape .extend (list (np_array .shape ))
581
- nd_proto .dense .dtype = np_array .dtype .str
582
- node_proto = NodeProto (ndarray = nd_proto , type = 'ndarray' )
583
-
578
+ node_proto = (
579
+ self .out_schema .__fields__ [k ]
580
+ .type_ .from_ndarray (np .array (v ))
581
+ ._to_node_protobuf ()
582
+ )
584
583
pb .data [k ].MergeFrom (node_proto )
585
584
586
585
doc = schema_cls .from_protobuf (pb )
You can’t perform that action at this time.
0 commit comments