@@ -537,7 +537,7 @@ def update_build_config(self, build_config: dict, field_value: str, field_name:
537
537
538
538
# Reload the list of collections and metadata associated
539
539
collection_options = self ._initialize_collection_options (
540
- api_endpoint = build_config ["d_api_endpoint" ]["value" ]
540
+ api_endpoint = build_config ["d_api_endpoint" ]["value" ] if not dslf else None
541
541
)
542
542
543
543
# If we have collections, show the dropdown
@@ -549,31 +549,34 @@ def update_build_config(self, build_config: dict, field_value: str, field_name:
549
549
# Hide embedding model option if opriona_metadata provider is not null
550
550
if field_name == "collection_name" and field_value :
551
551
# Set the options for collection name to be the field value if its a new collection
552
- if not dslf and field_value not in build_config ["collection_name" ]["options" ]:
553
- # Add the new collection to the list of options
554
- build_config ["collection_name" ]["options" ].append (field_value )
555
- build_config ["collection_name" ]["options_metadata" ].append (
556
- {"records" : 0 , "provider" : None , "icon" : "" , "model" : None }
557
- )
558
-
559
- # Ensure that autodetect collection is set to False
560
- build_config ["autodetect_collection" ]["value" ] = False
552
+ if field_value not in build_config ["collection_name" ]["options" ]:
553
+ # If this is running in DSLF, we may need to initialize the options again
554
+ if dslf :
555
+ # Reload the list of collections and metadata associated
556
+ collection_options = self ._initialize_collection_options (
557
+ api_endpoint = build_config ["d_api_endpoint" ]["value" ] if not dslf else None
558
+ )
559
+
560
+ # If we have collections, show the dropdown
561
+ build_config ["collection_name" ]["options" ] = [col ["name" ] for col in collection_options ]
562
+ build_config ["collection_name" ]["options_metadata" ] = [
563
+ {k : v for k , v in col .items () if k not in ["name" ]} for col in collection_options
564
+ ]
565
+ else :
566
+ # Add the new collection to the list of options
567
+ build_config ["collection_name" ]["options" ].append (field_value )
568
+ build_config ["collection_name" ]["options_metadata" ].append (
569
+ {"records" : 0 , "provider" : None , "icon" : "" , "model" : None }
570
+ )
571
+
572
+ # Ensure that autodetect collection is set to False, since its a new collection
573
+ build_config ["autodetect_collection" ]["value" ] = False
561
574
else :
562
575
build_config ["autodetect_collection" ]["value" ] = True
563
576
564
- # Find location of the name in the options list
577
+ # Find the position of the selected collection to align with metadata
565
578
index_of_name = build_config ["collection_name" ]["options" ].index (field_value )
566
579
567
- # Return if not found
568
- if index_of_name == - 1 :
569
- return build_config
570
-
571
- # Check if the number of records is 0
572
- if build_config ["collection_name" ]["options_metadata" ][index_of_name ]["records" ] == 0 :
573
- build_config ["autodetect_collection" ]["value" ] = False
574
- else :
575
- build_config ["autodetect_collection" ]["value" ] = True
576
-
577
580
# Get the provider value of the selected collection
578
581
value_of_provider = build_config ["collection_name" ]["options_metadata" ][index_of_name ]["provider" ]
579
582
0 commit comments