🔨 refactor(nodes.py): extract common field attributes to variables and set them accordingly
This commit extracts common field attributes to variables and sets them accordingly. The basic_fields and advanced_fields variables are used to set the show and advanced attributes of the fields. The API Key field is now displayed as "API Key" and its value is hidden. The location field now has a default value of ":memory:" and its placeholder is also set to ":memory:". The password attribute of the key fields is set to False. Issue Implement Qdrant #361
This commit is contained in:
parent
6f94fa60bc
commit
56da636915
4 changed files with 215 additions and 31 deletions
|
|
@ -108,6 +108,7 @@ utilities:
|
|||
- SQLDatabase
|
||||
vectorstores:
|
||||
- Chroma
|
||||
- Qdrant
|
||||
wrappers:
|
||||
- RequestsWrapper # Wait more tests
|
||||
# - ChatPromptTemplate
|
||||
|
|
|
|||
|
|
@ -634,6 +634,26 @@ class VectorStoreFrontendNode(FrontendNode):
|
|||
@staticmethod
|
||||
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
|
||||
FrontendNode.format_field(field, name)
|
||||
# Define common field attributes
|
||||
basic_fields = ["work_dir", "collection_name", "api_key", "location"]
|
||||
advanced_fields = [
|
||||
"n_dim",
|
||||
"key",
|
||||
"prefix",
|
||||
"distance_func",
|
||||
"content_payload_key",
|
||||
"metadata_payload_key",
|
||||
"timeout",
|
||||
"host",
|
||||
"path",
|
||||
"url",
|
||||
"port",
|
||||
"https",
|
||||
"prefer_grpc",
|
||||
"grpc_port",
|
||||
]
|
||||
|
||||
# Check and set field attributes
|
||||
if field.name == "texts":
|
||||
field.name = "documents"
|
||||
field.field_type = "TextSplitter"
|
||||
|
|
@ -642,7 +662,7 @@ class VectorStoreFrontendNode(FrontendNode):
|
|||
field.show = True
|
||||
field.advanced = False
|
||||
|
||||
if "embedding" in field.name:
|
||||
elif "embedding" in field.name:
|
||||
# for backwards compatibility
|
||||
field.name = "embedding"
|
||||
field.required = True
|
||||
|
|
@ -651,9 +671,18 @@ class VectorStoreFrontendNode(FrontendNode):
|
|||
field.display_name = "Embedding"
|
||||
field.field_type = "Embeddings"
|
||||
|
||||
elif field.name == "n_dim":
|
||||
field.show = True
|
||||
field.advanced = True
|
||||
elif field.name == "work_dir":
|
||||
elif field.name in basic_fields:
|
||||
field.show = True
|
||||
field.advanced = False
|
||||
if field.name == "api_key":
|
||||
field.display_name = "API Key"
|
||||
field.password = True
|
||||
elif field.name == "location":
|
||||
field.value = ":memory:"
|
||||
field.placeholder = ":memory:"
|
||||
|
||||
elif field.name in advanced_fields:
|
||||
field.show = True
|
||||
field.advanced = True
|
||||
if "key" in field.name:
|
||||
field.password = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue