fix: Add async aupdate_build_config to CustomComponent (#5181)
* Add async aupdate_build_config to CustomComponent * Add test of backward compatibility
This commit is contained in:
parent
a302a946f2
commit
4f5d7d93ad
17 changed files with 141 additions and 151 deletions
|
|
@ -1,10 +1,15 @@
|
|||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from langflow.components.agents import AgentComponent
|
||||
from langflow.components.crewai import CrewAIAgentComponent, SequentialTaskComponent
|
||||
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.schema import dotdict
|
||||
from langflow.template import Output
|
||||
from typing_extensions import override
|
||||
|
||||
|
||||
def test_set_invalid_output():
|
||||
|
|
@ -58,3 +63,21 @@ def test_set_required_inputs_various_components():
|
|||
assert _assert_all_outputs_have_different_required_inputs(chatoutput.outputs)
|
||||
assert _assert_all_outputs_have_different_required_inputs(task.outputs)
|
||||
assert _assert_all_outputs_have_different_required_inputs(agent.outputs)
|
||||
|
||||
|
||||
async def test_update_build_config_backward_compatibility():
|
||||
class TestComponent(CustomComponent):
|
||||
@override
|
||||
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 component.aupdate_build_config(build_config, "", "")
|
||||
assert build_config["foo"] == "bar"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue