fix: Expose API Endpoint when no DB list access in Astra (#5886)
* fix: Expose API Endpoint when no DB list access in Astra * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Update starter template * [autofix.ci] apply automated fixes * Update Vector Store RAG.json * Update astradb.py * [autofix.ci] apply automated fixes * Update astradb.py * [autofix.ci] apply automated fixes * Update astradb.py * [autofix.ci] apply automated fixes * Small update to dropdown for OSS * [autofix.ci] apply automated fixes * fix: Don't delete value when refreshing db list * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
d035e41e63
commit
5910638c9c
2 changed files with 187 additions and 185 deletions
|
|
@ -125,7 +125,7 @@ class AstraDBVectorStoreComponent(LCVectorStoreComponent):
|
||||||
),
|
),
|
||||||
StrInput(
|
StrInput(
|
||||||
name="api_endpoint",
|
name="api_endpoint",
|
||||||
display_name="API Endpoint",
|
display_name="Astra DB API Endpoint" if os.getenv("LANGFLOW_HOST") is None else "Database",
|
||||||
info="The API endpoint for the Astra DB instance.",
|
info="The API endpoint for the Astra DB instance.",
|
||||||
advanced=os.getenv("LANGFLOW_HOST") is None, # TODO: Clean up all examples of these
|
advanced=os.getenv("LANGFLOW_HOST") is None, # TODO: Clean up all examples of these
|
||||||
refresh_button=True,
|
refresh_button=True,
|
||||||
|
|
@ -169,12 +169,12 @@ class AstraDBVectorStoreComponent(LCVectorStoreComponent):
|
||||||
value="",
|
value="",
|
||||||
),
|
),
|
||||||
DropdownInput(
|
DropdownInput(
|
||||||
name="vectorize_choice",
|
name="embedding_choice",
|
||||||
display_name="Embedding Model or Astra Vectorize",
|
display_name="Embedding Model or Astra Vectorize",
|
||||||
info="Choose an embedding model or use Astra Vectorize.",
|
info="Choose an embedding model or use Astra Vectorize.",
|
||||||
options=["Embedding Model", "Astra Vectorize"],
|
options=["Embedding Model", "Astra Vectorize"],
|
||||||
value="Embedding Model",
|
value="Embedding Model",
|
||||||
show=os.getenv("LANGFLOW_HOST") is not None,
|
advanced=os.getenv("LANGFLOW_HOST") is None,
|
||||||
real_time_refresh=True,
|
real_time_refresh=True,
|
||||||
),
|
),
|
||||||
StrInput(
|
StrInput(
|
||||||
|
|
@ -502,7 +502,7 @@ class AstraDBVectorStoreComponent(LCVectorStoreComponent):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None):
|
def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None):
|
||||||
if field_name == "vectorize_choice":
|
if field_name == "embedding_choice":
|
||||||
if field_value == "Astra Vectorize":
|
if field_value == "Astra Vectorize":
|
||||||
build_config["embedding_model"]["show"] = False
|
build_config["embedding_model"]["show"] = False
|
||||||
build_config["embedding_model"]["required"] = False
|
build_config["embedding_model"]["required"] = False
|
||||||
|
|
@ -522,14 +522,21 @@ class AstraDBVectorStoreComponent(LCVectorStoreComponent):
|
||||||
# Reset the list of collections
|
# Reset the list of collections
|
||||||
build_config["collection_name"]["options"] = []
|
build_config["collection_name"]["options"] = []
|
||||||
build_config["collection_name"]["options_metadata"] = []
|
build_config["collection_name"]["options_metadata"] = []
|
||||||
build_config["database_name"]["value"] = []
|
|
||||||
|
|
||||||
# Get the list of databases
|
# Get the list of databases
|
||||||
database_options = self._initialize_database_options()
|
database_options = self._initialize_database_options()
|
||||||
build_config["database_name"]["options"] = [db["name"] for db in database_options]
|
|
||||||
build_config["database_name"]["options_metadata"] = [
|
if database_options and not os.getenv("LANGFLOW_HOST"):
|
||||||
{k: v for k, v in db.items() if k not in ["name"]} for db in database_options
|
build_config["database_name"]["show"] = True
|
||||||
]
|
build_config["api_endpoint"]["advanced"] = True
|
||||||
|
build_config["api_endpoint"]["value"] = ""
|
||||||
|
build_config["database_name"]["options"] = [db["name"] for db in database_options]
|
||||||
|
build_config["database_name"]["options_metadata"] = [
|
||||||
|
{k: v for k, v in db.items() if k not in ["name"]} for db in database_options
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
build_config["database_name"]["show"] = False
|
||||||
|
build_config["api_endpoint"]["advanced"] = False
|
||||||
|
|
||||||
# Get list of regions for a given cloud provider
|
# Get list of regions for a given cloud provider
|
||||||
"""
|
"""
|
||||||
|
|
@ -544,12 +551,8 @@ class AstraDBVectorStoreComponent(LCVectorStoreComponent):
|
||||||
] = self.map_cloud_providers()[cloud_provider]["regions"]
|
] = self.map_cloud_providers()[cloud_provider]["regions"]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return build_config
|
|
||||||
|
|
||||||
# Refresh the collection name options
|
# Refresh the collection name options
|
||||||
if field_name in ["database_name", "api_endpoint"] or not build_config["collection_name"]["options"]:
|
if field_name in ["database_name", "api_endpoint"] or not build_config["collection_name"]["options"]:
|
||||||
build_config["collection_name"]["value"] = None
|
|
||||||
|
|
||||||
# Reset the list of collections
|
# Reset the list of collections
|
||||||
collection_options = self._initialize_collection_options()
|
collection_options = self._initialize_collection_options()
|
||||||
build_config["collection_name"]["options"] = [col["name"] for col in collection_options]
|
build_config["collection_name"]["options"] = [col["name"] for col in collection_options]
|
||||||
|
|
@ -568,9 +571,11 @@ class AstraDBVectorStoreComponent(LCVectorStoreComponent):
|
||||||
if value_of_provider:
|
if value_of_provider:
|
||||||
build_config["embedding_model"]["advanced"] = True
|
build_config["embedding_model"]["advanced"] = True
|
||||||
build_config["embedding_model"]["required"] = False
|
build_config["embedding_model"]["required"] = False
|
||||||
|
build_config["embedding_choice"]["value"] = "Astra Vectorize"
|
||||||
else:
|
else:
|
||||||
build_config["embedding_model"]["advanced"] = False
|
build_config["embedding_model"]["advanced"] = False
|
||||||
build_config["embedding_model"]["required"] = True
|
build_config["embedding_model"]["required"] = True
|
||||||
|
build_config["embedding_choice"]["value"] = "Embedding Model"
|
||||||
|
|
||||||
# For the final step, get the list of vectorize providers
|
# For the final step, get the list of vectorize providers
|
||||||
"""
|
"""
|
||||||
|
|
@ -618,9 +623,10 @@ class AstraDBVectorStoreComponent(LCVectorStoreComponent):
|
||||||
# Get the embedding model and additional params
|
# Get the embedding model and additional params
|
||||||
embedding_params = (
|
embedding_params = (
|
||||||
{"embedding": self.embedding_model}
|
{"embedding": self.embedding_model}
|
||||||
if self.embedding_model and self.vectorize_choice == "Embedding Model"
|
if self.embedding_model and self.embedding_choice == "Embedding Model"
|
||||||
else {}
|
else {}
|
||||||
)
|
)
|
||||||
|
|
||||||
additional_params = self.astradb_vectorstore_kwargs or {}
|
additional_params = self.astradb_vectorstore_kwargs or {}
|
||||||
|
|
||||||
# Get Langflow version and platform information
|
# Get Langflow version and platform information
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue