From ba21c4e7176eb84a860edb1b8b9cfe74821addab Mon Sep 17 00:00:00 2001 From: Larry Yan Date: Mon, 2 Sep 2019 20:19:59 +0800 Subject: [PATCH] fix(service): fix bug for doc type in encoder --- gnes/service/encoder.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gnes/service/encoder.py b/gnes/service/encoder.py index 43421e92..95d2f969 100644 --- a/gnes/service/encoder.py +++ b/gnes/service/encoder.py @@ -43,8 +43,11 @@ def embed_chunks_in_docs(self, docs: Union[List['gnes_pb2.Document'], 'gnes_pb2. for c in d.chunks: if d.doc_type == gnes_pb2.Document.TEXT: contents.append(c.text) - else: + elif d.doc_type in {gnes_pb2.Document.IMAGE, gnes_pb2.Document.VIDEO}: contents.append(blob2array(c.blob)) + else: + self.logger.warning( + 'chunk content is in type: %s, dont kow how to handle that, ignored' % c.WhichOneof('content')) if do_encoding: embeds = self._model.encode(contents)