Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "an unexpected keyword argument 'cache_folder'" during import #1713

Open
CyberBearSec opened this issue Jun 25, 2024 · 0 comments
Open

Comments

@CyberBearSec
Copy link

CyberBearSec commented Jun 25, 2024

I have the following code into which I am passing in a JSON document. It keeps throwing the same error. I checked the JSOn and it is valid - what am I doing wrong?

Error: TypeError: SentenceTransformer.init() got an unexpected keyword argument 'cache_folder'

I am using Chroma through LangChain.

```
db_directory = os.path.join(user_directory, database_name + ".db")
embedding_function = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
# Cosine will keep the similarity scores between zero and one
chroma_db = Chroma(persist_directory=db_directory, collection_name=collection_name, 
embedding_function=embedding_function,
                       collection_metadata={"hnsw:space": "cosine"}, relevance_score_fn=lambda distance: 1.0 - distance / 2)
json_splitter = RecursiveJsonSplitter(max_chunk_size=2000)
docs = json_splitter.create_documents(json_splitter.split_json(json_object))
if doc_ids is None:
    doc_ids = [str(uuid.uuid4()) for i in range(1, len(docs) + 1)]
else:
    # We look to see if the document exists:
    result = chroma_db.get(doc_ids)
    if result is not None and len(result) > 0:
        # This is an update:
        chroma_db.update_documents(doc_ids, docs)
        return doc_ids
chroma_db.from_documents(docs, embedding_function, ids=doc_ids)
return doc_ids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant