Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow basic Astra DB Collection creation in combobox #5958

Merged
merged 5 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/backend/base/langflow/components/vectorstores/astradb.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,10 @@ def update_build_config(self, build_config: dict, field_value: str, field_name:
# Define variables for common database conditions a user may experience
is_hosted = os.getenv("LANGFLOW_HOST") is not None
no_databases = "options" not in build_config["api_endpoint"] or not build_config["api_endpoint"]["options"]
no_api_endpoint = not build_config["api_endpoint"]["value"]

# Refresh the database name options
if not is_hosted and (field_name in ["token", "environment"] or no_databases):
if not is_hosted and (field_name in ["token", "environment"] or (no_databases and no_api_endpoint)):
# Get the list of options we have based on the token provided
database_options = self._initialize_database_options()

Expand Down Expand Up @@ -524,11 +525,8 @@ def update_build_config(self, build_config: dict, field_value: str, field_name:
] = self.map_cloud_providers()[cloud_provider]["regions"]
"""

# Define variables for common collection conditions a user may experience
no_collections = not build_config["collection_name"]["options"]

# Refresh the collection name options
if field_name == "api_endpoint" or (field_name == "collection_name" and no_collections):
if field_name == "api_endpoint":
# Reset the selected collection
build_config["collection_name"]["value"] = ""

Expand All @@ -539,11 +537,15 @@ def update_build_config(self, build_config: dict, field_value: str, field_name:
{k: v for k, v in col.items() if k not in ["name"]} for col in collection_options
]

# Define variables for common collection choice conditions a user may experience
collection_chosen = field_value and build_config["collection_name"]["options"]

# Hide embedding model option if opriona_metadata provider is not null
if field_name == "collection_name" and collection_chosen:
if field_name == "collection_name" and field_value:
# Set the options for collection name to be the field value if its a new collection
if not is_hosted and field_value not in build_config["collection_name"]["options"]:
build_config["collection_name"]["options"].append(field_value)
build_config["collection_name"]["options_metadata"].append(
{"records": 0, "provider": None, "icon": "", "model": None}
)

# Find location of the name in the options list
index_of_name = build_config["collection_name"]["options"].index(field_value)
value_of_provider = build_config["collection_name"]["options_metadata"][index_of_name]["provider"]
Expand Down
Loading
Loading