Skip to content

Commit 21df99b

Browse files
committed
feat(cli): add a note to get_embedding_function error message. Fix #46
1 parent 43df44c commit 21df99b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/vectorcode/common.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def get_collection_name(full_path: str) -> str:
134134
return collection_id
135135

136136

137-
def get_embedding_function(configs: Config) -> chromadb.EmbeddingFunction:
137+
def get_embedding_function(configs: Config) -> chromadb.EmbeddingFunction | None:
138138
try:
139139
return getattr(embedding_functions, configs.embedding_function)(
140140
**configs.embedding_params
@@ -145,6 +145,16 @@ def get_embedding_function(configs: Config) -> chromadb.EmbeddingFunction:
145145
file=sys.stderr,
146146
)
147147
return embedding_functions.SentenceTransformerEmbeddingFunction()
148+
except Exception as e:
149+
print(
150+
f"Failed to use {configs.embedding_function} with the following error:",
151+
file=sys.stderr,
152+
)
153+
e.add_note(
154+
"\nFor errors caused by missing dependency, consult the documentation of pipx (or whatever package manager that you installed VectorCode with) for instructions to inject libraries into the virtual environment."
155+
)
156+
157+
raise
148158

149159

150160
__COLLECTION_CACHE: dict[str, AsyncCollection] = {}

0 commit comments

Comments
 (0)