fix: made reranker not disable when hybrid search is enabled (#7622)

* added toggle_disable option

* made toggle be disabled when toggle_disable is true

* added logic to disable toggle when choosing hybrid search

* Updated starter projects

* Fixed toggle_disable to be optional

* fixed toggle disable to remove toggle

* ✅ (intComponent.spec.ts): update test assertions to match expected behavior after changes in the component's functionality

---------

Co-authored-by: Carlos Coelho <80289056+carlosrcoelho@users.noreply.github.com>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
This commit is contained in:
Lucas Oliveira 2025-04-14 20:47:14 -03:00 • committed by GitHub
commit 7fb400d99e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 19 additions and 4 deletions

View file

@ -827,7 +827,9 @@ class AstraDBVectorStoreComponent(LCVectorStoreComponent):
build_config["search_method"]["value"] = "Vector Search" build_config["search_method"]["value"] = "Vector Search"
# Set reranker and lexical terms options based on search method # Set reranker and lexical terms options based on search method
build_config["reranker"]["toggle_value"] = True
build_config["reranker"]["show"] = build_config["search_method"]["value"] == "Hybrid Search" build_config["reranker"]["show"] = build_config["search_method"]["value"] == "Hybrid Search"
build_config["reranker"]["toggle_disable"] = build_config["search_method"]["value"] == "Hybrid Search"
if build_config["reranker"]["show"]: if build_config["reranker"]["show"]:
build_config["search_type"]["value"] = "Similarity" build_config["search_type"]["value"] = "Similarity"
@ -887,6 +889,11 @@ class AstraDBVectorStoreComponent(LCVectorStoreComponent):
build_config["lexical_terms"]["show"] = not is_vector_search build_config["lexical_terms"]["show"] = not is_vector_search
build_config["lexical_terms"]["value"] = "" if is_vector_search else build_config["lexical_terms"]["value"] build_config["lexical_terms"]["value"] = "" if is_vector_search else build_config["lexical_terms"]["value"]
# Disable reranker disabling if hybrid search is selected
build_config["reranker"]["toggle_disable"] = not is_vector_search
build_config["reranker"]["toggle_value"] = True
build_config["reranker"]["value"] = build_config["reranker"]["options"][0]
# Toggle search type and score threshold based on search method # Toggle search type and score threshold based on search method
build_config["search_type"]["show"] = is_vector_search build_config["search_type"]["show"] = is_vector_search
build_config["search_score_threshold"]["show"] = is_vector_search build_config["search_score_threshold"]["show"] = is_vector_search

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -206,6 +206,8 @@ class DropDownMixin(BaseModel):
"""Variable that defines if a toggle button is shown.""" """Variable that defines if a toggle button is shown."""
toggle_value: bool | None = None toggle_value: bool | None = None
"""Variable that defines the value of the toggle button. Defaults to None.""" """Variable that defines the value of the toggle button. Defaults to None."""
toggle_disable: bool | None = None
"""Variable that defines if the toggle button is disabled. Defaults to None."""
@field_validator("toggle_value") @field_validator("toggle_value")
@classmethod @classmethod

View file

@ -469,6 +469,7 @@ class DropdownInput(BaseInputMixin, DropDownMixin, MetadataTraceMixin, ToolModeM
combobox: CoalesceBool = False combobox: CoalesceBool = False
dialog_inputs: dict[str, Any] = Field(default_factory=dict) dialog_inputs: dict[str, Any] = Field(default_factory=dict)
toggle: bool = False toggle: bool = False
toggle_disable: bool | None = None
toggle_value: bool | None = None toggle_value: bool | None = None

View file

@ -18,6 +18,7 @@ export default function DropdownComponent({
handleNodeClass, handleNodeClass,
toggle, toggle,
toggleValue, toggleValue,
toggleDisable,
...baseInputProps ...baseInputProps
}: InputProps<string, DropDownComponentType>) { }: InputProps<string, DropDownComponentType>) {
const onChange = (value: any, dbValue?: boolean, skipSnapshot?: boolean) => { const onChange = (value: any, dbValue?: boolean, skipSnapshot?: boolean) => {
@ -44,7 +45,7 @@ export default function DropdownComponent({
handleOnNewValue={handleOnNewValue} handleOnNewValue={handleOnNewValue}
{...baseInputProps} {...baseInputProps}
/> />
{toggle && ( {toggle && toggleDisable !== true ? (
<ToggleShadComponent <ToggleShadComponent
value={toggleValue ?? true} value={toggleValue ?? true}
handleOnNewValue={(data) => { handleOnNewValue={(data) => {
@ -57,6 +58,8 @@ export default function DropdownComponent({
id={`toggle_dropdown_${id}`} id={`toggle_dropdown_${id}`}
disabled={disabled} disabled={disabled}
/> />
) : (
<></>
)} )}
</div> </div>
); );

View file

@ -78,6 +78,7 @@ export function StrRenderComponent({
name={templateData?.name!} name={templateData?.name!}
toggle={templateData.toggle} toggle={templateData.toggle}
toggleValue={templateData.toggle_value} toggleValue={templateData.toggle_value}
toggleDisable={templateData.toggle_disable}
/> />
); );
} }

View file

@ -99,6 +99,7 @@ export type DropDownComponentType = {
handleNodeClass: (value: any, code?: string, type?: string) => void; handleNodeClass: (value: any, code?: string, type?: string) => void;
toggle?: boolean; toggle?: boolean;
toggleValue?: boolean; toggleValue?: boolean;
toggleDisable?: boolean;
}; };
export type TextAreaComponentType = { export type TextAreaComponentType = {