alnzng commented on code in PR #332:
URL: https://github.com/apache/flink-agents/pull/332#discussion_r2605447094
##########
python/flink_agents/api/vector_stores/vector_store.py:
##########
@@ -85,11 +91,18 @@ class Document(BaseModel):
"""
content: str = Field(description="The actual text content of the
document.")
- metadata: Dict[str, Any] = Field(default_factory=dict,
description="Document metadata such as source, author, timestamp, etc.")
- id: str | None = Field(default=None, description="Unique identifier of the
document.")
+ metadata: Dict[str, Any] = Field(
+ default_factory=dict,
+ description="Document metadata such as source, author, timestamp,
etc.",
+ )
+ id: str | None = Field(
+ default=None, description="Unique identifier of the document."
+ )
Review Comment:
Out of curiosity, did we change the code format stype? seems there are many
diffs like this
##########
python/flink_agents/api/vector_stores/vector_store.py:
##########
@@ -135,6 +152,40 @@ def store_kwargs(self) -> Dict[str, Any]:
when performing vector search operations.
"""
+ def add(
+ self, documents: Document | List[Document], collection_name: str |
None = None, **kwargs: Any
Review Comment:
The newly added CRUD methods look flexible enough to handle operations
across multiple collections, which is good. However, the current vector store
implementation is limited to a single collection. To keep the behavior
consistent, we should update the existing implementation to support multiple
collections as well. For example, For example, the `query`implementation needs
to be extended to support retrieval from multiple collections to align with the
new CRUD methods.
##########
python/flink_agents/api/vector_stores/vector_store.py:
##########
@@ -135,6 +152,40 @@ def store_kwargs(self) -> Dict[str, Any]:
when performing vector search operations.
"""
+ def add(
+ self, documents: Document | List[Document], collection_name: str |
None = None, **kwargs: Any
+ ) -> List[str]:
+ """Add documents to the vector store.
+
+ Converts document content to embeddings and stores them in the vector
store.
+ The implementation may generate IDs for documents that don't have one.
+
+ Args:
+ documents: Single Document or list of Documents to add.
+ collection_name: The collection name of the documents to add to.
Optional.
+ **kwargs: Vector store specific parameters.
+
+ Returns:
+ List of document IDs that were added to the vector store
+ """
+ # Normalize to list
+ documents = maybe_cast_to_list(documents)
+
+ # Generate embeddings for all documents
+ embedding_model = self.get_resource(
+ self.embedding_model, ResourceType.EMBEDDING_MODEL
+ )
+
+ # Generate embeddings for each document
+ embeddings = [embedding_model.embed(doc.content) for doc in documents]
Review Comment:
Chroma seems to have a size limitation on each request when persisting
embeddings, batches should contain fewer than 41,666 embeddings. This has been
discussed in the Chroma community (see [GitHub issue
#1049](https://github.com/chroma-core/chroma/issues/1049)). I’m not sure if
this restriction has changed recently, but to be safe we should add a check for
requests exceeding 41,666 embeddings, similar to how LlamaIndex handles it
today:
https://github.com/run-llama/llama_index/blob/main/llama-index-integrations/vector_stores/llama-index-vector-stores-chroma/llama_index/vector_stores/chroma/base.py#L97C1-L97C72
That being said, it may be better to abstract the embedding function at the
document level and allow each vector store implementation to override it as
needed.
##########
python/flink_agents/runtime/memory/tests/start_chroma_server.sh:
##########
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+path=$1
+chroma run --path $path
Review Comment:
To enable PersistentClient[1], specify `persist_directory` parameter while
building the `ChromaVectorStore` should help. IIUC, this is similar to what
"--path $path" parameter offer in chroma CLI.
[1] https://docs.trychroma.com/docs/run-chroma/persistent-client
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]