Use local vectordb installation (pip version is too old and buggy)

This commit is contained in:
pancake 2024-01-11 04:23:05 +01:00
parent 7b7b66828f
commit c80748188c
3 changed files with 22 additions and 8 deletions

View File

@ -12,6 +12,10 @@ all:
deps:
python -m pip install -r requirements.txt
vectordb:
git clone https://github.com/kagisearch/vectordb
cd vectordb && python setup.py build
install user-install:
ln -fs $(PWD)/main.py $(R2_USER_PLUGINS)/r2ai.py
ln -fs $(PWD)/main.py $(R2PM_BINDIR)/r2ai

View File

@ -8,9 +8,14 @@ os.environ["TOKENIZERS_PARALLELISM"]="false"
try:
r2aihome = os.path.dirname(os.readlink(__file__))
sys.path.append(r2aihome)
# if available
sys.path.append(f"{r2aihome}/../vectordb")
except:
pass
# run `make vectordb` because pip install vectordb2 is too old
sys.path.append(f"vectordb")
import traceback
import r2ai
from r2ai.utils import slurp

View File

@ -248,14 +248,19 @@ def vectordb_init():
try:
import vectordb
have_vectordb = True
except:
have_vectordb = False
print("To better data index use:")
print(" pip install vectordb2")
print("On macOS you'll need to also do this:")
print(" python -m pip install spacy")
print(" python -m spacy download en_core_web_sm")
return
except Exception as e:
os.system("python -m spacy download en_core_web_sm")
try:
import vectordb
have_vectordb = True
except:
have_vectordb = False
print("To better data index use:")
print(" pip install vectordb2")
print("On macOS you'll need to also do this:")
print(" python -m pip install spacy")
print(" python -m spacy download en_core_web_sm")
return
try:
vectordb_instance = vectordb.Memory(embeddings="best") # normal or fast
except: