mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-23 17:58:35 +08:00
fix: Remove blanket real_time_refresh options stripping and add dynamic loading to CurrentDate (#11400)
* fix: Update timezone options loading for CurrentDateComponent * fix: Remove real-time refresh options stripping to stabilize component index * Enhance component options in component_index.json - Added language model options for agent_llm: "Anthropic", "OpenAI" and "OpenAI", "Custom". - Introduced model_name option: "Select a model". - Expanded HTTP method options for method: "GET", "POST", "PATCH", "PUT", "DELETE". - Updated mode options to include: "URL", "cURL". - Added search_mode options: "Web", "News", "RSS". - Defined environment options for Astra DB API Endpoint: "prod", "test", "dev". - Specified search_method options: "Hybrid Search", "Vector Search". - Included chunker options: "HybridChunker", "HierarchicalChunker". - Added tokenizer provider options: "Hugging Face", "OpenAI". - Defined export_format options: "Markdown", "HTML", "Plaintext", "DocTags". - Introduced auth_mode options: "basic", "jwt". - Updated pipeline options: "standard", "vlm". - Specified storage_location options for reading and saving files: "Local", "AWS", "Google Drive". - Expanded operator options for text comparison. - Updated repo_source options: "Local", "Remote". - Updated dependencies version for google to "2.5.0". - Added model_id options for Hugging Face Hub. - Defined base_url options for IBM API. - Updated mode options for message operations: "Retrieve", "Store". - Enhanced mirostat options: "Disabled", "Mirostat", "Mirostat 2.0". - Expanded model_name options for various GPT models. - Updated DataFrame operation options with icons. - Enhanced text operation options with icons. - Specified output_type options: "Message", "Data", "DataFrame". - Updated CurrentDateComponent to dynamically load timezone options. * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
5814774464
commit
60e3ab4970
@ -65,25 +65,6 @@ def _strip_dynamic_fields(obj):
|
||||
return obj
|
||||
|
||||
|
||||
def _strip_realtime_refresh_options(obj):
|
||||
"""Strip options from fields that have real_time_refresh=True.
|
||||
|
||||
These fields populate their options dynamically at runtime via update_build_config,
|
||||
so including them in the index creates unnecessary churn when external data changes
|
||||
(e.g., LiteLLM model lists).
|
||||
"""
|
||||
if isinstance(obj, dict):
|
||||
# Check if this is a field with real_time_refresh=True
|
||||
if obj.get("real_time_refresh") is True and "options" in obj:
|
||||
# Return a copy with options cleared
|
||||
return {k: _strip_realtime_refresh_options(v) if k != "options" else [] for k, v in obj.items()}
|
||||
# Recurse into all dict values
|
||||
return {k: _strip_realtime_refresh_options(v) for k, v in obj.items()}
|
||||
if isinstance(obj, list):
|
||||
return [_strip_realtime_refresh_options(item) for item in obj]
|
||||
return obj
|
||||
|
||||
|
||||
def _import_components() -> tuple[dict, int]:
|
||||
"""Import all lfx components using the async import function.
|
||||
|
||||
@ -156,11 +137,6 @@ def build_component_index() -> dict:
|
||||
print("\nStripping dynamic fields from component metadata...")
|
||||
index = _strip_dynamic_fields(index)
|
||||
|
||||
# Strip options from fields with real_time_refresh=True
|
||||
# These fields populate their options dynamically at runtime
|
||||
print("Stripping options from real_time_refresh fields...")
|
||||
index = _strip_realtime_refresh_options(index)
|
||||
|
||||
# Normalize the entire structure for deterministic output
|
||||
index = _normalize_for_determinism(index)
|
||||
|
||||
@ -201,7 +177,6 @@ def main():
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Pretty-print for readable git diffs and resolvable merge conflicts
|
||||
# With dynamic options stripped, the file is stable and conflicts are manageable
|
||||
print(f"\nWriting formatted index to {output_path}")
|
||||
json_bytes = orjson.dumps(index, option=orjson.OPT_SORT_KEYS | orjson.OPT_INDENT_2)
|
||||
output_path.write_text(json_bytes.decode("utf-8"), encoding="utf-8")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1651,7 +1651,7 @@
|
||||
},
|
||||
"CurrentDate": {
|
||||
"versions": {
|
||||
"0.3.0": "8311e820e80c"
|
||||
"0.3.0": "4a93d7b489e6"
|
||||
}
|
||||
},
|
||||
"IDGenerator": {
|
||||
|
||||
@ -18,12 +18,20 @@ class CurrentDateComponent(Component):
|
||||
DropdownInput(
|
||||
name="timezone",
|
||||
display_name="Timezone",
|
||||
options=sorted(tz for tz in available_timezones() if tz != "localtime"),
|
||||
options=[], # Options loaded dynamically via update_build_config
|
||||
value="UTC",
|
||||
info="Select the timezone for the current date and time.",
|
||||
tool_mode=True,
|
||||
real_time_refresh=True,
|
||||
),
|
||||
]
|
||||
|
||||
def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None): # noqa: ARG002
|
||||
"""Dynamically update build config with timezone options."""
|
||||
if field_name == "timezone" or field_name is None:
|
||||
build_config["timezone"]["options"] = sorted(tz for tz in available_timezones() if tz != "localtime")
|
||||
return build_config
|
||||
|
||||
outputs = [
|
||||
Output(display_name="Current Date", name="current_date", method="get_current_date"),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user