Skip to content

Commit

Permalink
Fix: Ensure compatibility with DSLF Overlays in Astra DB Component (#…
Browse files Browse the repository at this point in the history
…5876)

* fix: address DSLF issues with Astra DB component

* Update Vector Store RAG.json

* [autofix.ci] apply automated fixes

* Update astradb.py

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
erichare and autofix-ci[bot] authored Jan 22, 2025
1 parent 1df53a8 commit 220727a
Show file tree
Hide file tree
Showing 2 changed files with 674 additions and 607 deletions.
28 changes: 26 additions & 2 deletions src/backend/base/langflow/components/vectorstores/astradb.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class NewCollectionInput:
name="api_endpoint",
display_name="API Endpoint",
info="The API endpoint for the Astra DB instance.",
advanced=True,
show=os.getenv("LANGFLOW_HOST") is not None, # TODO: Clean up all examples of these
),
DropdownInput(
name="database_name",
Expand All @@ -145,6 +145,7 @@ class NewCollectionInput:
],
value="",
combobox=True,
show=os.getenv("LANGFLOW_HOST") is None,
),
DropdownInput(
name="collection_name",
Expand All @@ -165,6 +166,15 @@ class NewCollectionInput:
],
value="",
),
DropdownInput(
name="vectorize_choice",
display_name="Embedding Model or Astra Vectorize",
info="Choose an embedding model or use Astra Vectorize.",
options=["Embedding Model", "Astra Vectorize"],
value="Embedding Model",
show=os.getenv("LANGFLOW_HOST") is not None,
real_time_refresh=True,
),
StrInput(
name="keyspace",
display_name="Keyspace",
Expand Down Expand Up @@ -490,6 +500,16 @@ def _initialize_collection_options(self):
return []

def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None):
if field_name == "vectorize_choice":
if field_value == "Astra Vectorize":
build_config["embedding_model"]["show"] = False
build_config["embedding_model"]["required"] = False
else:
build_config["embedding_model"]["show"] = True
build_config["embedding_model"]["required"] = True

return build_config

if not self.token or not self.token.startswith("AstraCS:"):
build_config["database_name"]["info"] = "Add a Valid Token to Select a Database"
else:
Expand Down Expand Up @@ -594,7 +614,11 @@ def build_vector_store(self):
raise ImportError(msg) from e

# Get the embedding model and additional params
embedding_params = {"embedding": self.embedding_model} if self.embedding_model else {}
embedding_params = (
{"embedding": self.embedding_model}
if self.embedding_model and self.vectorize_choice == "Embedding Model"
else {}
)
additional_params = self.astradb_vectorstore_kwargs or {}

# Get Langflow version and platform information
Expand Down
Loading

0 comments on commit 220727a

Please sign in to comment.