Open marfal opened 1 month ago
Hey @marfal, I'm here to help you with any bugs, questions, or contributions you have. Let's get to the bottom of this together!
The errors you're encountering with the NotifyComponent
and ListenComponent
are due to the absence of the build_results
method in these components. This method is crucial for constructing the results and artifacts for a component, as it gathers inputs, initiates a tracing context, and generates the outputs [1][2].
To resolve this issue, you need to ensure that both NotifyComponent
and ListenComponent
implement the build_results
method. This method should handle the processing of inputs and generation of outputs, similar to how it's done in other components within Langflow.
Regarding the input compatibility issue, Langflow uses a mechanism to map inputs and outputs to ensure they can connect correctly. You should verify that the input and output types for these components are defined using the appropriate classes, such as MessageTextInput
for inputs and Output
for outputs, and that they are compatible with other components [3][4].
By implementing the build_results
method and ensuring input/output compatibility, you should be able to resolve the errors and make the NotifyComponent
and ListenComponent
functional.
To continue talking to Dosu, mention @dosu.
Any idea to fix it?
Patching up the connectors is fairly straightforward but the componentes are incomplete otherwise, it seems. Even after trying to implement the build_result I was never able to get them working correctly (probably due to my limited skills and knowledge of Langflow).
Hello @marfal @guoguoguilai the components were in an old format, they are still going to be reformulated that's why they are in beta. I have updated both of them.
@joaoguilhermeS Hi. I appreciate your help, but I guess these components are just not ready from the prime time yet. While the connector handles seem to be of a correct type now, there is still an error when trying to actually build/run the components. For example notify gies this error: Error building Component Notify NEW:
cannot access local variable 'data' where it is not associated with a value
Traceback (most recent call last):
File "/app/.venv/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 727, in _build_results
result = await initialize.loading.get_instance_results(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 67, in get_instance_results
return await build_component(params=custom_params, custom_component=custom_component)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 153, in build_component
build_results, artifacts = await custom_component.build_results()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/langflow/custom/custom_component/component.py", line 707, in build_results
return await self._build_with_tracing()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/langflow/custom/custom_component/component.py", line 695, in _build_with_tracing
_results, _artifacts = await self._build_results()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/langflow/custom/custom_component/component.py", line 731, in _build_results
result = method()
^^^^^^^^
File "
GPT ;) suggests this resolution:
def build_notify(self) -> Data:
data = None # Initialize data variable
if self.data:
if not isinstance(self.data, Data):
if isinstance(self.data, str):
data = Data(text=self.data)
elif isinstance(self.data, dict):
data = Data(data=self.data)
else:
data = Data(text=str(self.data))
else:
data = self.data # If self.data is already a Data object, use it directly
else:
data = Data(text="") # Default value for data if self.data is None
if data:
if self.append:
self.append_state(self.name, data)
else:
self.update_state(self.name, data)
else:
self.status = "No record provided."
self.status = data
self._set_successors_ids()
return data
Which seems to work, but again the rest of the logic is not working as expected and the two components do not work in unison es expected.
Hey @marfal , although I didn't initially encounter the problem, I was able to replicate and fix it along with some other minor issues. I believe everything is now fully resolved and will be opening a PR soon to definitively address it. In the meantime, you can use this flow: Notify and Listen - Example.json.
Bug Description
Notify and Listen components have Data and Text inputs that are incompatible with other nodes. Additionally both components throw error:
Error building Component Notify:
'NotifyComponent' object has no attribute 'build_results'
Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 727, in _build_results result = await initialize.loading.get_instance_results( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 67, in get_instance_results return await build_component(params=custom_params, custom_component=custom_component) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 153, in build_component build_results, artifacts = await custom_component.build_results() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NotifyComponent' object has no attribute 'build_results'
And similarly: Error building Component Listen:
'ListenComponent' object has no attribute 'build_results'
Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 727, in _build_results result = await initialize.loading.get_instance_results( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 67, in get_instance_results return await build_component(params=custom_params, custom_component=custom_component) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 153, in build_component build_results, artifacts = await custom_component.build_results() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ListenComponent' object has no attribute 'build_results'
Rendering them unusable.
Reproduction
Expected behavior
Expect input Data handle and Text handle to connect with correct inputs/outputs and for Notify and Listen components to execute correctly.
Who can help?
@ogabrielluiz @nicoloboschi
Operating System
Ubuntu Linux 22.04
Langflow Version
v1.0.19.post1
Python Version
None
Screenshot
Flow File
No response