This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 0d093655eb NIFI-13433 Fixed PutChroma handling of list values in 
properties
0d093655eb is described below

commit 0d093655eb8de192fb39c7ab14f5cf10646f55b2
Author: Krisztina Zsihovszki <kzsihovs...@cloudera.com>
AuthorDate: Wed Jun 26 11:45:19 2024 +0200

    NIFI-13433 Fixed PutChroma handling of list values in properties
    
    This closes #9007
    
    Signed-off-by: David Handermann <exceptionfact...@apache.org>
---
 .../src/main/python/vectorstores/PutChroma.py                 | 11 +++++++++--
 .../src/main/python/vectorstores/QueryChroma.py               |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git 
a/nifi-python-extensions/nifi-text-embeddings-module/src/main/python/vectorstores/PutChroma.py
 
b/nifi-python-extensions/nifi-text-embeddings-module/src/main/python/vectorstores/PutChroma.py
index ec8f208425..bdeff89e22 100644
--- 
a/nifi-python-extensions/nifi-text-embeddings-module/src/main/python/vectorstores/PutChroma.py
+++ 
b/nifi-python-extensions/nifi-text-embeddings-module/src/main/python/vectorstores/PutChroma.py
@@ -62,7 +62,7 @@ class PutChroma(FlowFileTransform):
     embedding_function = None
 
     def __init__(self, **kwargs):
-        self.property_descriptors = [prop for prop in ChromaUtils.PROPERTIES] 
+ [prop for prop in EmbeddingUtils.PROPERTIES]
+        self.property_descriptors = [prop for prop in ChromaUtils.PROPERTIES] 
+ [prop for prop in EmbeddingUtils.PROPERTIES if prop != 
EmbeddingUtils.EMBEDDING_MODEL]
         self.property_descriptors.append(self.STORE_TEXT)
         self.property_descriptors.append(self.DISTANCE_METHOD)
         self.property_descriptors.append(self.DOC_ID_FIELD_NAME)
@@ -103,7 +103,14 @@ class PutChroma(FlowFileTransform):
             filtered_metadata = {}
             for key, value in metadata.items():
                 if value is not None:
-                    filtered_metadata[key] = value
+                    if isinstance(value, list):
+                        element_count = 0
+                        for element in value:
+                            element_count += 1
+                            indexed_key = f"{key}_{element_count}"
+                            filtered_metadata[indexed_key] = element
+                    else:
+                        filtered_metadata[key] = value
 
             metadatas.append(filtered_metadata)
 
diff --git 
a/nifi-python-extensions/nifi-text-embeddings-module/src/main/python/vectorstores/QueryChroma.py
 
b/nifi-python-extensions/nifi-text-embeddings-module/src/main/python/vectorstores/QueryChroma.py
index d2e6c46db3..1ede516c51 100644
--- 
a/nifi-python-extensions/nifi-text-embeddings-module/src/main/python/vectorstores/QueryChroma.py
+++ 
b/nifi-python-extensions/nifi-text-embeddings-module/src/main/python/vectorstores/QueryChroma.py
@@ -75,7 +75,7 @@ class QueryChroma(FlowFileTransform):
     include_embeddings = None
     results_field = None
 
-    property_descriptors = [prop for prop in ChromaUtils.PROPERTIES] + [prop 
for prop in EmbeddingUtils.PROPERTIES] + [
+    property_descriptors = [prop for prop in ChromaUtils.PROPERTIES] + [prop 
for prop in EmbeddingUtils.PROPERTIES if prop != 
EmbeddingUtils.EMBEDDING_MODEL] + [
         QUERY,
         NUMBER_OF_RESULTS,
         QueryUtils.OUTPUT_STRATEGY,

Reply via email to