Skip to content

Commit 56fc11a

Browse files
authored
feat: Update ChromaSearch and ChromaComponent to use chromadb library (#1992)
The code changes in `ChromaSearch.py` and `Chroma.py` import the `chromadb` library and use it to create a `HttpClient` object. This change enables the components to interact with a Chroma server for vector search functionality. This commit message follows the established convention of starting with a type (feat for feature) and providing a concise summary of the changes.
1 parent 1a4b895 commit 56fc11a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/backend/base/langflow/components/vectorsearch/ChromaSearch.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import List, Optional
22

3+
import chromadb
34
from chromadb.config import Settings
45
from langchain_chroma import Chroma
56

@@ -91,7 +92,7 @@ def build(
9192

9293
# Chroma settings
9394
chroma_settings = None
94-
95+
client = None
9596
if chroma_server_host is not None:
9697
chroma_settings = Settings(
9798
chroma_server_cors_allow_origins=chroma_server_cors_allow_origins or [],
@@ -100,13 +101,14 @@ def build(
100101
chroma_server_grpc_port=chroma_server_grpc_port or None,
101102
chroma_server_ssl_enabled=chroma_server_ssl_enabled,
102103
)
104+
client = chromadb.HttpClient(settings=chroma_settings)
103105
if index_directory:
104106
index_directory = self.resolve_path(index_directory)
105107
vector_store = Chroma(
106108
embedding_function=embedding,
107109
collection_name=collection_name,
108110
persist_directory=index_directory,
109-
client_settings=chroma_settings,
111+
client=client,
110112
)
111113

112114
return self.search_with_vector_store(input_value, search_type, vector_store, k=number_of_results)

src/backend/base/langflow/components/vectorstores/Chroma.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import List, Optional, Union
22

3+
import chromadb
34
from chromadb.config import Settings
45
from langchain_chroma import Chroma
56
from langchain_core.embeddings import Embeddings
@@ -81,7 +82,7 @@ def build(
8182

8283
# Chroma settings
8384
chroma_settings = None
84-
85+
client = None
8586
if chroma_server_host is not None:
8687
chroma_settings = Settings(
8788
chroma_server_cors_allow_origins=chroma_server_cors_allow_origins or [],
@@ -90,6 +91,7 @@ def build(
9091
chroma_server_grpc_port=chroma_server_grpc_port or None,
9192
chroma_server_ssl_enabled=chroma_server_ssl_enabled,
9293
)
94+
client = chromadb.HttpClient(settings=chroma_settings)
9395

9496
# If documents, then we need to create a Chroma instance using .from_documents
9597

@@ -111,12 +113,12 @@ def build(
111113
persist_directory=index_directory,
112114
collection_name=collection_name,
113115
embedding=embedding,
114-
client_settings=chroma_settings,
116+
client=client,
115117
)
116118
else:
117119
chroma = Chroma(
118120
persist_directory=index_directory,
119-
client_settings=chroma_settings,
121+
client=client,
120122
embedding_function=embedding,
121123
)
122124
return chroma

0 commit comments

Comments
 (0)