refactor: improve attribute compatibility and error messages (#3367)

* feat: Refactor how configuration attributes are handled in Component class.

* refactor: Update method name to handle singular and plural inputs.

* refactor: Add value validation for input and attribute assignment.

* test: Add test for setting invalid input in task component.

* fix: add param without underscore to inputs

* test(astra): Refactor AstraDB imports in test_astra_component (#3413)

* test(astra): Refactor AstraDB imports in test_astra_component

* fix: Add AstraVectorizeComponent to AstraDB tests.

* fix: Refactor custom component error message for setting parameter or attribute.

* test(astra): Refactor AstraDB imports in test_astra_component (#3413)

* test(astra): Refactor AstraDB imports in test_astra_component

* fix: Add AstraVectorizeComponent to AstraDB tests.

* chore: Refactor joining methods list in _set_parameter_or_attribute function.

* refactor: Refactor error message string formatting in Component class.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-08-21 09:34:15 -03:00 committed by GitHub
commit bf650ecec5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 1 deletions

View file

@ -1,5 +1,7 @@
import pytest
from langflow.components.agents.CrewAIAgent import CrewAIAgentComponent
from langflow.components.helpers.SequentialTask import SequentialTaskComponent
from langflow.components.inputs.ChatInput import ChatInput
from langflow.components.outputs import ChatOutput
@ -14,3 +16,13 @@ def test_set_invalid_output():
chatoutput = ChatOutput()
with pytest.raises(ValueError):
chatoutput.set(input_value=chatinput.build_config)
def test_set_invalid_input():
crewai_agent = CrewAIAgentComponent()
task = SequentialTaskComponent()
with pytest.raises(
ValueError,
match="You set CrewAI Agent as value for `agent`. You should pass one of the following: 'build_output'",
):
task.set(agent=crewai_agent)