mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-19 12:03:54 +02:00
fix chat image upload double read
This commit is contained in:
@@ -717,8 +717,6 @@ def upload_files_for_chat(
|
|||||||
else ChatFileType.PLAIN_TEXT
|
else ChatFileType.PLAIN_TEXT
|
||||||
)
|
)
|
||||||
|
|
||||||
file_content = file.file.read() # Read the file content
|
|
||||||
|
|
||||||
if file_type == ChatFileType.IMAGE:
|
if file_type == ChatFileType.IMAGE:
|
||||||
file_content_io = file.file
|
file_content_io = file.file
|
||||||
# NOTE: Image conversion to JPEG used to be enforced here.
|
# NOTE: Image conversion to JPEG used to be enforced here.
|
||||||
@@ -727,7 +725,7 @@ def upload_files_for_chat(
|
|||||||
# 2. Maintain transparency in formats like PNG
|
# 2. Maintain transparency in formats like PNG
|
||||||
# 3. Ameliorate issue with file conversion
|
# 3. Ameliorate issue with file conversion
|
||||||
else:
|
else:
|
||||||
file_content_io = io.BytesIO(file_content)
|
file_content_io = io.BytesIO(file.file.read())
|
||||||
|
|
||||||
new_content_type = file.content_type
|
new_content_type = file.content_type
|
||||||
|
|
||||||
@@ -745,7 +743,7 @@ def upload_files_for_chat(
|
|||||||
# to re-extract it every time we send a message
|
# to re-extract it every time we send a message
|
||||||
if file_type == ChatFileType.DOC:
|
if file_type == ChatFileType.DOC:
|
||||||
extracted_text = extract_file_text(
|
extracted_text = extract_file_text(
|
||||||
file=io.BytesIO(file_content), # use the bytes we already read
|
file=file_content_io, # use the bytes we already read
|
||||||
file_name=file.filename or "",
|
file_name=file.filename or "",
|
||||||
)
|
)
|
||||||
text_file_id = str(uuid.uuid4())
|
text_file_id = str(uuid.uuid4())
|
||||||
|
Reference in New Issue
Block a user