mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-18 04:43:55 +00:00
fix: arXiv PDF links reach the model as raw bytes (#32524)
Files read from a URL are sent to a document parser based on their file name. An arXiv link like arxiv.org/pdf/1706.03762 has a dot in the paper ID, so the name was read as having the extension ".03762", the PDF went to the plain text reader and the model got raw PDF bytes. When the part after the dot is not a known file type, the extension now comes from the file type the server reports, so these links are read as PDFs. Files the server only labels as generic binary keep their name as before.
This commit is contained in:
parent
a5942da0a2
commit
823670d9fa
1 changed files with 3 additions and 0 deletions
|
|
@ -120,6 +120,9 @@ def _extract_text_from_binary_response(
|
|||
if not filename or '.' not in filename:
|
||||
ext = mimetypes.guess_extension(content_type) or ''
|
||||
filename = f'download{ext}'
|
||||
elif not mimetypes.guess_type(filename)[0] and content_type != 'application/octet-stream':
|
||||
# The dot in names like arXiv's 1706.03762 is not an extension.
|
||||
filename += mimetypes.guess_extension(content_type) or ''
|
||||
|
||||
suffix = '.' + filename.split('.')[-1].lower() if '.' in filename else ''
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue