From c2c6421f0df1f81c229c67d283064fe93a9a7daa Mon Sep 17 00:00:00 2001 From: thecaptain789 Date: Sat, 7 Feb 2026 03:52:44 +0000 Subject: [PATCH] fix: fall back to mimetypes when puremagic returns empty string --- llm/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/llm/utils.py b/llm/utils.py index 58194bd6a..4a7ebd68d 100644 --- a/llm/utils.py +++ b/llm/utils.py @@ -3,6 +3,7 @@ import httpx import itertools import json +import mimetypes import pathlib import puremagic import re @@ -46,9 +47,13 @@ def mimetype_from_string(content) -> Optional[str]: def mimetype_from_path(path) -> Optional[str]: try: type_ = puremagic.from_file(path, mime=True) - return MIME_TYPE_FIXES.get(type_, type_) + if type_: + return MIME_TYPE_FIXES.get(type_, type_) except puremagic.PureError: - return None + pass + # Fall back to mimetypes for common extensions + mime_type, _ = mimetypes.guess_type(str(path)) + return mime_type def dicts_to_table_string(