Skip to content

Commit

Permalink
fix chat image upload double read
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-w committed Feb 4, 2025
1 parent 715359c commit c061bf9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions backend/onyx/server/query_and_chat/chat_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,6 @@ def upload_files_for_chat(
else ChatFileType.PLAIN_TEXT
)

file_content = file.file.read() # Read the file content

if file_type == ChatFileType.IMAGE:
file_content_io = file.file
# NOTE: Image conversion to JPEG used to be enforced here.
Expand All @@ -723,7 +721,7 @@ def upload_files_for_chat(
# 2. Maintain transparency in formats like PNG
# 3. Ameliorate issue with file conversion
else:
file_content_io = io.BytesIO(file_content)
file_content_io = io.BytesIO(file.file.read())

new_content_type = file.content_type

Expand All @@ -741,7 +739,7 @@ def upload_files_for_chat(
# to re-extract it every time we send a message
if file_type == ChatFileType.DOC:
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 "",
)
text_file_id = str(uuid.uuid4())
Expand Down

0 comments on commit c061bf9

Please sign in to comment.