mirror of
https://github.com/langgenius/dify.git
synced 2026-04-05 09:49:25 +08:00
fix: support qa_preview shape in IndexProcessor preview formatting (#34151)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Crazywoola <100913391+crazywoola@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
beda78e911
commit
09ee8ea1f5
@@ -35,7 +35,10 @@ class IndexProcessor:
|
||||
if "parent_mode" in preview:
|
||||
data.parent_mode = preview["parent_mode"]
|
||||
|
||||
for item in preview["preview"]:
|
||||
# Different index processors return different preview shapes:
|
||||
# - paragraph/parent-child processors: {"preview": [...]}
|
||||
# - QA processor: {"qa_preview": [...]} (no "preview" key)
|
||||
for item in preview.get("preview", []):
|
||||
if "content" in item and "child_chunks" in item:
|
||||
data.preview.append(
|
||||
PreviewItem(content=item["content"], child_chunks=item["child_chunks"], summary=None)
|
||||
@@ -44,6 +47,10 @@ class IndexProcessor:
|
||||
data.qa_preview.append(QaPreview(question=item["question"], answer=item["answer"]))
|
||||
elif "content" in item:
|
||||
data.preview.append(PreviewItem(content=item["content"], child_chunks=None, summary=None))
|
||||
|
||||
for item in preview.get("qa_preview", []):
|
||||
if "question" in item and "answer" in item:
|
||||
data.qa_preview.append(QaPreview(question=item["question"], answer=item["answer"]))
|
||||
return data
|
||||
|
||||
def index_and_clean(
|
||||
|
||||
Reference in New Issue
Block a user