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

⚡️ Speed up method AstraDBVectorStoreComponent.reset_database_list by 36% in PR #6236 (LFOSS-492) #6641

Closed
Closed
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
17 changes: 13 additions & 4 deletions src/backend/base/langflow/components/vectorstores/astradb.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ def collection_data(self, collection_name: str, database: Database | None = None

def _initialize_database_options(self):
try:
database_list = self.get_database_list()
return [
{
"name": name,
Expand All @@ -490,7 +491,7 @@ def _initialize_database_options(self):
"api_endpoint": info["api_endpoint"],
"icon": "data",
}
for name, info in self.get_database_list().items()
for name, info in database_list.items()
]
except Exception as e:
msg = f"Error fetching database options: {e}"
Expand Down Expand Up @@ -580,13 +581,21 @@ def reset_database_list(self, build_config: dict):
database_options = self._initialize_database_options()

# If we retrieved options based on the token, show the dropdown
build_config["database_name"]["options"] = [db["name"] for db in database_options]
database_names = [db["name"] for db in database_options]
build_config["database_name"]["options"] = database_names

build_config["database_name"]["options_metadata"] = [
{k: v for k, v in db.items() if k not in ["name"]} for db in database_options
{
"status": db["status"],
"collections": db["collections"],
"api_endpoint": db["api_endpoint"],
"icon": db["icon"],
}
for db in database_options
]

# Reset the selected database
if build_config["database_name"]["value"] not in build_config["database_name"]["options"]:
if build_config["database_name"]["value"] not in database_names:
build_config["database_name"]["value"] = ""
build_config["api_endpoint"]["value"] = ""
build_config["collection_name"]["advanced"] = True
Expand Down
Loading
Loading