Notify and Listen components throw error: object has no attribute 'build_results' + incompatible component inputs
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
- Add component Notify and/or Listen on the canvas.
- Select Data input handle or Name input handle
- See the available list of available inputs / connective components
- Try to build/run Notify and/or Listen components
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
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.
@joaoguilhermeS Maybe I'm a bit confused -- I thought the purpose of notify/listen is that you don't need to have them connected and they would be "connected" via the event name. So that if the notifier fires the event, then the listener automatically picks it up and runs. For example:
Will this not work?
I tested this and I didn't see any chat output:
@SnakeO, you are right, this is still ongoing work and might be fixed soon. Feel free to contribute to the PR as well.
Thank you @joaoguilhermeS -- can you explain in plain english how this might be accomplished without having an input connected to the listener, and I'll see if I can get it working?
I'm not sure how to tell langflow to "begin execution on the listener node"
+1 seeing the same error, any plans to fix this
also kindly clarify if this fix will make notify -> listen work without explicitly connecting them
any news on this ?
Hi, @marfal. I'm Dosu, and I'm helping the langflow team manage their backlog. I'm marking this issue as stale.
Issue Summary:
- The Notify and Listen components have errors due to a missing 'build_results' attribute.
- You reported ongoing issues even after updates, including an unbound local variable 'data'.
- @joaoguilhermeS acknowledged the issues and mentioned a forthcoming PR.
- Questions about the components' functionality without direct connections remain unresolved.
Next Steps:
- Please let me know if this issue is still relevant to the latest version of the langflow repository by commenting here.
- If no updates are provided, the issue will be automatically closed in 7 days.
Thank you for your understanding and contribution!