ref: Add and use update_component_build_config utility (#5226)
* Add and use update_component_build_config utility * [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
5a4aef0f82
commit
384ac5e80e
21 changed files with 78 additions and 50 deletions
|
|
@ -7,6 +7,7 @@ from langflow.components.custom_component import CustomComponent
|
|||
from langflow.components.inputs import ChatInput
|
||||
from langflow.components.models import OpenAIModelComponent
|
||||
from langflow.components.outputs import ChatOutput
|
||||
from langflow.custom.utils import update_component_build_config
|
||||
from langflow.schema import dotdict
|
||||
from langflow.template import Output
|
||||
from typing_extensions import override
|
||||
|
|
@ -65,7 +66,7 @@ def test_set_required_inputs_various_components():
|
|||
assert _assert_all_outputs_have_different_required_inputs(agent.outputs)
|
||||
|
||||
|
||||
async def test_update_build_config_backward_compatibility():
|
||||
async def test_update_component_build_config_sync():
|
||||
class TestComponent(CustomComponent):
|
||||
@override
|
||||
def update_build_config(
|
||||
|
|
@ -79,5 +80,23 @@ async def test_update_build_config_backward_compatibility():
|
|||
|
||||
component = TestComponent()
|
||||
build_config = dotdict()
|
||||
build_config = await component.aupdate_build_config(build_config, "", "")
|
||||
build_config = await update_component_build_config(component, build_config, "", "")
|
||||
assert build_config["foo"] == "bar"
|
||||
|
||||
|
||||
async def test_update_component_build_config_async():
|
||||
class TestComponent(CustomComponent):
|
||||
@override
|
||||
async def update_build_config(
|
||||
self,
|
||||
build_config: dotdict,
|
||||
field_value: Any,
|
||||
field_name: str | None = None,
|
||||
):
|
||||
build_config["foo"] = "bar"
|
||||
return build_config
|
||||
|
||||
component = TestComponent()
|
||||
build_config = dotdict()
|
||||
build_config = await update_component_build_config(component, build_config, "", "")
|
||||
assert build_config["foo"] == "bar"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue