Skip to content

Commit 6002862

Browse files
committed
replace unicode errors
1 parent a6f82a0 commit 6002862

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

knowledge_gpt/core/parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def from_bytes(cls, file: BytesIO) -> "PdfFile":
8888
class TxtFile(File):
8989
@classmethod
9090
def from_bytes(cls, file: BytesIO) -> "TxtFile":
91-
text = file.read().decode("utf-8")
91+
text = file.read().decode("utf-8", errors="replace")
9292
text = strip_consecutive_newlines(text)
9393
file.seek(0)
9494
doc = Document(page_content=text.strip())

knowledge_gpt/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
try:
6464
file = read_file(uploaded_file)
6565
except Exception as e:
66-
display_file_read_error(e)
66+
display_file_read_error(e, file_name=uploaded_file.name)
6767

6868
chunked_file = chunk_file(file, chunk_size=300, chunk_overlap=0)
6969

knowledge_gpt/ui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def is_file_valid(file: File) -> bool:
3636
return True
3737

3838

39-
def display_file_read_error(e: Exception) -> NoReturn:
39+
def display_file_read_error(e: Exception, file_name: str) -> NoReturn:
4040
st.error("Error reading file. Make sure the file is not corrupted or encrypted")
41-
logger.error(f"{e.__class__.__name__}: {e}")
41+
logger.error(f"{e.__class__.__name__}: {e}. Extension: {file_name.split('.')[-1]}")
4242
st.stop()
4343

4444

0 commit comments

Comments
 (0)