Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions llm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import httpx
import itertools
import json
import mimetypes
import pathlib
import puremagic
import re
Expand Down Expand Up @@ -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(
Expand Down