Custom component error (Component has not been built yet)
Bug Description
When connecting text inputs - all is ok, but when you want connect custom component with text input - langflow thrown an error. Need to connect 2 or more custom components, with one custom component all is ok.
Reproduction
- create custom component returning message
- clone component
- add text input component
- connect all components (custom -> custom -> text input)
- try to run it
Expected behavior
text input component should receive text from custom componentn
Who can help?
@italojohnny
Operating System
Docker
Langflow Version
1.1.3
Python Version
None
Screenshot
Flow File
Hey there, @Bal1! I'm here to help you with any bugs, questions, or contributions. Feel free to ask for assistance while we wait for a human maintainer.
I found a similar solved discussion that might be relevant to your issue. The discussion titled Component Running Error addresses issues with custom components not running correctly alongside front-end components. Here are some potential causes and solutions mentioned:
- Name Overlap: Ensure there is no overlap between the names of inputs and outputs in your custom component.
- Reserved Attribute Names: Verify that your custom component does not use reserved attribute names for its inputs or outputs.
- Component Validation: Make sure your custom component is properly validated for compatibility with front-end components.
- Execution Order: Check the execution order of your components. Langflow uses a topological sort to manage execution order, so ensure that your custom component is correctly integrated into this flow.
- Error Logging: Utilize Langflow's logging capabilities to identify specific errors.
Review these aspects of your custom component and its integration with the text input to identify and resolve the issue [1].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other
@dosu I changed component names, all component are working separatelly, but when running last element - error appears:
When connecting multiple custom components in Langflow, ensure that there are no overlapping names between inputs and outputs, as this can cause conflicts and errors [1]. Additionally, verify that each component is properly validated and compatible with the others. Langflow uses a Directed Acyclic Graph (DAG) to manage execution order, so ensure that your components are correctly integrated into this flow [2].
If the error persists, check the specific error messages or logs generated by Langflow. Common errors include invalid return types, type conversion issues, or problems building components [3]. These logs can provide more insight into what might be causing the issue.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other
@dosu I changed output names also, but issue exists.
Error log:
Component Component2 has not been built yet
Traceback (most recent call last):
File "/app/.venv/lib/python3.12/site-packages/langflow/api/v1/chat.py", line 242, in _build_vertex
vertex_build_result = await graph.build_vertex(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/langflow/graph/graph/base.py", line 1440, in build_vertex
await vertex.build(
File "/app/.venv/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 839, in build
await step(user_id=user_id, event_manager=event_manager, **kwargs)
File "/app/.venv/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 485, in _build
await self._build_each_vertex_in_params_dict()
File "/app/.venv/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 576, in _build_each_vertex_in_params_dict
await self._build_vertex_and_update_params(
File "/app/.venv/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 671, in _build_vertex_and_update_params
result = await vertex.get_result(self, target_handle_name=key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 621, in get_result
return await self._get_result(requester, target_handle_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/langflow/graph/vertex/vertex_types.py", line 114, in _get_result
raise ValueError(msg)
ValueError: Component Component2 has not been built yet
The error message "Component Component2 has not been built yet" suggests that the component is not being executed in the correct order or is missing necessary inputs. Here are some steps to troubleshoot and resolve the issue:
-
Check Dependencies: Ensure that all dependencies for "Component2" are correctly set up and that it receives the necessary inputs from "Component1". Verify that the connections between components are properly established.
-
Execution Order: Langflow uses a Directed Acyclic Graph (DAG) to manage execution order. Make sure that "Component2" is correctly integrated into this flow and that there are no cycles or missing connections that could disrupt the order [1].
-
Component Validation: Double-check that "Component2" is properly validated and compatible with the other components. Ensure that it is correctly defined and that all required parameters are set.
-
Error Logging: Review the error logs for any additional details that might indicate what is preventing "Component2" from being built. Look for issues related to parameter handling or type mismatches.
-
Rebuild Components: Try rebuilding the components individually using the Play button to ensure they work independently before connecting them in the flow [2].
By following these steps, you should be able to identify and resolve the issue with "Component2" not being built.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other
@italojohnny maybe you can help with this issue?
hi @Bal1,
When you are returning a value, you have to construct the class you are returning It. probably you have missed this step. Look at the Custom Component code that works:
# from langflow.field_typing import Data
from langflow.custom import Component
from langflow.io import MessageTextInput, Output
from langflow.schema import Data
class CustomComponent(Component):
display_name = "Custom Component"
description = "Use as a template to create your own component."
documentation: str = "http://docs.langflow.org/components/custom"
icon = "code"
name = "CustomComponent"
inputs = [
MessageTextInput(
name="input_value",
display_name="Input Value",
info="This is a custom component Input",
value="Hello, World!",
tool_mode=True,
),
]
outputs = [
Output(display_name="Output", name="output", method="build_output"),
]
def build_output(self) -> Message:
return Message(
text=self.input_value,
)
def build_output(self) -> Message: return Message( text=self.input_value, )
@Cristhianzl can you open an example I attached?
all custom components have a class in return method, but when you connect it to langflow component (for example text) it stop working. just add text input to bottom line of components and you will see the error.
Hi @Bal1,
Got it! You were absolutely right—the Vertex build wasn’t applying this rule as expected. Please follow up on this PR with the fix: #6155.
Thanks a lot for your collaboration!