while two "NestedDict" data set advance False in a custom component, error happen
liaochf opened this issue · comments
liaochf commented
from typing import Optional, Union
from langchain.schema import BaseRetriever, Document
from langflow import CustomComponent
from langchain_community.vectorstores import VectorStore, Milvus
from langchain.embeddings.base import Embeddings
from langflow.field_typing import NestedDict,Embeddings,Document
class MilvusVectorStore(CustomComponent):
display_name: str = "Milvus"
description: str = "Implementation of Vector Store using Milvus"
documentation = "https://python.langchain.com/docs/integrations/vectorstores/milvus"
beta = True
field_config = {
"connection_args": {
"display_name": "Connection Args",
"field_type": "NestedDict",
"required": True,
"value": {
"host": "localhost",
"port": "19530",
"user": "",
"password": ""
}
},
"collection_name": {
"display_name": "Collection Name",
"field_type": "str",
"required": False,
},
"documents": {
"display_name": "Documents",
"field_type": "Document",
"is_list": True
},
"embedding_function": {
"display_name": "Embedding",
"required": True,
"field_type": "Embeddings"
},
"index_params": {
"display_name": "Index Parameters",
"required": False,
"field_type": "NestedDict",
"advanced": F,
},
"search_params": {
"display_name": "Search Parameters",
"field_type": "NestedDict",
"advanced": True,
},
"text_field":{
"display_name": "Text Field",
"field_type": "str",
},
"vector_field":{
"display_name": "Vector Field",
"field_type": "str",
},
"code": {"show": False},
}
def build(
self,
connection_args: NestedDict,
collection_name: Optional[str] = None,
index_params: Optional[NestedDict] = None,
search_params: Optional[NestedDict] = None,
embedding_function: Optional[Embeddings] = None,
documents: Optional[Document] = None
) -> Union[VectorStore, BaseRetriever]:
if documents is not None and embedding_function is not None:
try:
vector_db = Milvus.from_documents(
documents=documents,
embedding=embedding_function,
connection_args=connection_args,
collection_name=collection_name,
index_params=index_params,
search_params=search_params
)
except Exception as e:
raise ValueError(str(e)) from e
try:
vector_db = Milvus(
connection_args=connection_args,
collection_name=collection_name,
embedding_function=embedding_function,
search_params=search_params,
index_params=index_params
)
except Exception as e:
raise ValueError(str(e)) from e
return vector_db
liaochf commented
Gabriel Luiz Freitas Almeida commented
Hey @liaochf
Thank you for reporting this.
Hey @Cristhianzl could you take a look at this, please? This is a problem in the stable version.