Преглед изворни кода

Fix: docx get image exception. (#7636)

### What problem does this PR solve?

Close #7631

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.19.0
Kevin Hu пре 5 месеци
родитељ
комит
bfe97d896d
No account linked to committer's email address
2 измењених фајлова са 4 додато и 0 уклоњено
  1. 3
    0
      rag/app/naive.py
  2. 1
    0
      rag/prompts.py

+ 3
- 0
rag/app/naive.py Прегледај датотеку

@@ -60,6 +60,9 @@ class Docx(DocxParser):
except InvalidImageStreamError:
logging.info("The recognized image stream appears to be corrupted. Skipping image.")
return None
except UnicodeDecodeError:
logging.info("The recognized image stream appears to be corrupted. Skipping image.")
return None
try:
image = Image.open(BytesIO(image_blob)).convert('RGB')
return image

+ 1
- 0
rag/prompts.py Прегледај датотеку

@@ -44,6 +44,7 @@ def chunks_format(reference):
"similarity": chunk.get("similarity"),
"vector_similarity": chunk.get("vector_similarity"),
"term_similarity": chunk.get("term_similarity"),
"doc_type": chunk.get("doc_type_kwd"),
}
for chunk in reference.get("chunks", [])
]

Loading…
Откажи
Сачувај