Skip to content

Commit b3e81ab

Browse files
committed
modify other components
1 parent 8492f3c commit b3e81ab

3 files changed

Lines changed: 49 additions & 15 deletions

File tree

src/lfx/src/lfx/components/llm_operations/lambda_filter.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
from typing import Any
77

88
from lfx.base.models.unified_models import (
9+
apply_provider_variable_config_to_build_config,
910
get_language_model_options,
1011
get_llm,
12+
get_provider_for_model_name,
1113
update_model_options_in_build_config,
1214
)
1315
from lfx.custom.custom_component.component import Component
@@ -116,7 +118,7 @@ class LambdaFilterComponent(Component):
116118

117119
def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None):
118120
"""Dynamically update build config with user-filtered model options."""
119-
return update_model_options_in_build_config(
121+
build_config = update_model_options_in_build_config(
120122
component=self,
121123
build_config=build_config,
122124
cache_key_prefix="language_model_options",
@@ -125,6 +127,19 @@ def update_build_config(self, build_config: dict, field_value: str, field_name:
125127
field_value=field_value,
126128
)
127129

130+
current_model_value = field_value if field_name == "model" else build_config.get("model", {}).get("value")
131+
provider = ""
132+
if isinstance(current_model_value, list) and current_model_value:
133+
selected_model = current_model_value[0]
134+
provider = (selected_model.get("provider") or "").strip()
135+
if not provider and selected_model.get("name"):
136+
provider = get_provider_for_model_name(str(selected_model["name"]))
137+
138+
if provider:
139+
build_config = apply_provider_variable_config_to_build_config(build_config, provider)
140+
141+
return build_config
142+
128143
def get_data_structure(self, data):
129144
"""Extract the structure of data, replacing values with their types."""
130145
if isinstance(data, list):

src/lfx/src/lfx/components/llm_operations/llm_conditional_router.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from typing import Any
22

33
from lfx.base.models.unified_models import (
4+
apply_provider_variable_config_to_build_config,
45
get_language_model_options,
56
get_llm,
7+
get_provider_for_model_name,
68
update_model_options_in_build_config,
79
)
810
from lfx.custom import Component
@@ -136,7 +138,7 @@ def __init__(self, **kwargs):
136138

137139
def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None):
138140
"""Dynamically update build config with user-filtered model options."""
139-
return update_model_options_in_build_config(
141+
build_config = update_model_options_in_build_config(
140142
component=self,
141143
build_config=build_config,
142144
cache_key_prefix="language_model_options",
@@ -145,6 +147,19 @@ def update_build_config(self, build_config: dict, field_value: str, field_name:
145147
field_value=field_value,
146148
)
147149

150+
current_model_value = field_value if field_name == "model" else build_config.get("model", {}).get("value")
151+
provider = ""
152+
if isinstance(current_model_value, list) and current_model_value:
153+
selected_model = current_model_value[0]
154+
provider = (selected_model.get("provider") or "").strip()
155+
if not provider and selected_model.get("name"):
156+
provider = get_provider_for_model_name(str(selected_model["name"]))
157+
158+
if provider:
159+
build_config = apply_provider_variable_config_to_build_config(build_config, provider)
160+
161+
return build_config
162+
148163
def update_outputs(self, frontend_node: dict, field_name: str, field_value: Any) -> dict:
149164
"""Create a dynamic output for each category in the categories table."""
150165
if field_name in {"routes", "enable_else_output", "model"}:

src/lfx/src/lfx/components/models_and_agents/embedding_model.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
from lfx.base.embeddings.embeddings_class import EmbeddingsWithModels
44
from lfx.base.embeddings.model import LCEmbeddingsModel
55
from lfx.base.models.unified_models import (
6+
apply_provider_variable_config_to_build_config,
67
get_api_key_for_provider,
78
get_embedding_class,
89
get_embedding_model_options,
10+
get_provider_for_model_name,
911
get_unified_models_detailed,
1012
update_model_options_in_build_config,
1113
)
@@ -34,7 +36,6 @@ class EmbeddingModelComponent(LCEmbeddingsModel):
3436

3537
def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None):
3638
"""Dynamically update build config with user-filtered model options."""
37-
# Update model options
3839
build_config = update_model_options_in_build_config(
3940
component=self,
4041
build_config=build_config,
@@ -44,20 +45,23 @@ def update_build_config(self, build_config: dict, field_value: str, field_name:
4445
field_value=field_value,
4546
)
4647

47-
# Show/hide provider-specific fields based on selected model
48-
if field_name == "model" and isinstance(field_value, list) and len(field_value) > 0:
49-
selected_model = field_value[0]
50-
provider = selected_model.get("provider", "")
48+
current_model_value = field_value if field_name == "model" else build_config.get("model", {}).get("value")
49+
provider = ""
50+
if isinstance(current_model_value, list) and current_model_value:
51+
selected_model = current_model_value[0]
52+
provider = (selected_model.get("provider") or "").strip()
53+
if not provider and selected_model.get("name"):
54+
provider = get_provider_for_model_name(str(selected_model["name"]))
5155

52-
# Show/hide watsonx fields
56+
if provider:
57+
build_config = apply_provider_variable_config_to_build_config(build_config, provider)
58+
59+
# Embedding-specific WatsonX toggles not covered by provider metadata
5360
is_watsonx = provider == "IBM WatsonX"
54-
build_config["base_url_ibm_watsonx"]["show"] = is_watsonx
55-
build_config["project_id"]["show"] = is_watsonx
56-
build_config["truncate_input_tokens"]["show"] = is_watsonx
57-
build_config["input_text"]["show"] = is_watsonx
58-
if is_watsonx:
59-
build_config["base_url_ibm_watsonx"]["required"] = True
60-
build_config["project_id"]["required"] = True
61+
if "truncate_input_tokens" in build_config:
62+
build_config["truncate_input_tokens"]["show"] = is_watsonx
63+
if "input_text" in build_config:
64+
build_config["input_text"]["show"] = is_watsonx
6165

6266
return build_config
6367

0 commit comments

Comments
 (0)