Fix chunk creation using Infinity (#3763)

### What problem does this PR solve?

1. Store error type in Infinity
2. position list value read from Infinity isn't correct.

Fix issue: #3729

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Signed-off-by: jinhai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2024-11-30 00:10:14 +08:00
committed by GitHub
parent a19210daf1
commit d00297a763
2 changed files with 9 additions and 1 deletions

View File

@ -60,6 +60,11 @@ def list_chunk():
sres = settings.retrievaler.search(query, search.index_name(tenant_id), kb_ids, highlight=True)
res = {"total": sres.total, "chunks": [], "doc": doc.to_dict()}
for id in sres.ids:
chunk_elem = sres.field[id]
if 'position_list' in chunk_elem:
if isinstance(chunk_elem["position_list"], str):
chunk_elem.pop('position_list') # Infinity will store position list as empty str
d = {
"chunk_id": id,
"content_with_weight": rmSpace(sres.highlight[id]) if question and id in sres.highlight else sres.field[