fix: initialize embedding function manually (#205)

This commit is contained in:
cachho
2023-07-11 13:38:48 +02:00
committed by GitHub
parent 34fd4180ec
commit 35b6e14328
2 changed files with 48 additions and 10 deletions

View File

@@ -297,6 +297,13 @@ class App(EmbedChain):
"""
if config is None:
config = InitConfig()
if not config.ef:
config._set_embedding_function_to_default()
if not config.db:
config._set_db_to_default()
super().__init__(config)
def get_llm_model_answer(self, prompt, config: ChatConfig):
@@ -345,17 +352,17 @@ class OpenSourceApp(EmbedChain):
"Loading open source embedding model. This may take some time..."
) # noqa:E501
if not config:
config = InitConfig(
ef=embedding_functions.SentenceTransformerEmbeddingFunction(
model_name="all-MiniLM-L6-v2"
)
)
elif not config.ef:
config = InitConfig()
if not config.ef:
config._set_embedding_function(
embedding_functions.SentenceTransformerEmbeddingFunction(
model_name="all-MiniLM-L6-v2"
)
)
embedding_functions.SentenceTransformerEmbeddingFunction(
model_name="all-MiniLM-L6-v2"
))
if not config.db:
config._set_db_to_default()
print("Successfully loaded open source embedding model.")
super().__init__(config)