Skip to content

Commit 748a737

Browse files
adding fallback to the content type (URLs only) into the Rabbit Hole (#15)
1 parent 3883899 commit 748a737

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

core/cat/rabbit_hole.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ async def __file_to_docs(
161161
request = httpx.get(file, headers={"User-Agent": "Magic Browser"})
162162

163163
# Define mime type and source of url
164-
content_type = request.headers["Content-Type"].split(";")[0]
164+
# Add fallback for empty/None content_type
165+
content_type = request.headers.get(
166+
"Content-Type", "text/html" if file.startswith(("http://", "https://")) else "text/plain"
167+
).split(";")[0]
165168
source = file
166169

167170
try:
@@ -183,6 +186,10 @@ async def __file_to_docs(
183186
if not file_bytes:
184187
raise ValueError(f"Something went wrong with the file {source}")
185188

189+
log.debug(f"Attempting to parse file: {source}")
190+
log.debug(f"Detected MIME type: {content_type}")
191+
log.debug(f"Available handlers: {list(stray.file_handlers.keys())}")
192+
186193
# Load the bytes in the Blob schema
187194
blob = Blob(data=file_bytes, mimetype=content_type).from_data(
188195
data=file_bytes, mime_type=content_type, path=source

core/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "Cheshire-Cat"
33
description = "Production ready AI assistant framework"
4-
version = "2.1.2"
4+
version = "2.1.3"
55
requires-python = ">=3.11"
66
license = { file = "LICENSE" }
77
authors = [

0 commit comments

Comments
 (0)