aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2024-07-28 02:58:02 +0000
committerAnthony Wang2024-07-28 02:58:02 +0000
commit7c6dad605fec72bdc8051fb7afabd0a3edeabc5c (patch)
tree36044f856c441be260ad498f3fcdb183cd8d25e2
parent945c2da5d02df0d1014e47cdef09d6f308078e62 (diff)
Don't index text since it interferes with other results
-rw-r--r--server.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/server.py b/server.py
index d1c41d5..43d3316 100644
--- a/server.py
+++ b/server.py
@@ -98,18 +98,16 @@ def index(path, parent):
# Modified or not in emb
emb = None
type = mimetypes.guess_type(path)[0]
- try:
- if type is None and os.path.getsize(path) < 2**16:
- with open(path) as f:
- emb = model.embed_text(f.read())
- elif type.startswith("audio"):
- emb = model.embed_audio(path)
- elif type.startswith("image"):
- emb = model.embed_image(path)
- elif type.startswith("video") and os.path.getsize(path) < 2**25:
- emb = model.embed_video(path)
- except:
- print(traceback.format_exc())
+ if isinstance(type, str):
+ try:
+ if type.startswith("audio"):
+ emb = model.embed_audio(path)
+ elif type.startswith("image"):
+ emb = model.embed_image(path)
+ elif type.startswith("video") and os.path.getsize(path) < 2**25:
+ emb = model.embed_video(path)
+ except:
+ print(traceback.format_exc())
if emb is None:
# Might be in index but no longer valid