Comments (1)
To avoid confusion caused by the term vertex
, you can replace it with a more descriptive term such as node
. Here is the corrected version of the error message and related code:
from langflow.graph.node import types
from langflow.interface.agents.base import agent_creator
from langflow.interface.chains.base import chain_creator
from langflow.interface.custom.base import custom_component_creator
from langflow.interface.document_loaders.base import documentloader_creator
from langflow.interface.embeddings.base import embedding_creator
from langflow.interface.llms.base import llm_creator
from langflow.interface.memories.base import memory_creator
from langflow.interface.output_parsers.base import output_parser_creator
from langflow.interface.prompts.base import prompt_creator
from langflow.interface.retrievers.base import retriever_creator
from langflow.interface.text_splitters.base import textsplitter_creator
from langflow.interface.toolkits.base import toolkits_creator
from langflow.interface.tools.base import tool_creator
from langflow.interface.wrappers.base import wrapper_creator
from langflow.utils.lazy_load import LazyLoadDictBase
class NodeTypesDict(LazyLoadDictBase):
def __init__(self):
self._all_types_dict = None
@property
def NODE_TYPE_MAP(self):
return self.all_types_dict
def _build_dict(self):
langchain_types_dict = self.get_type_dict()
return {
**langchain_types_dict,
"Custom": ["Custom Tool", "Python Function"],
}
def get_custom_component_node_type(self):
return types.CustomComponentNode
def get_type_dict(self):
return {
**{t: types.PromptNode for t in prompt_creator.to_list()},
**{t: types.AgentNode for t in agent_creator.to_list()},
**{t: types.ChainNode for t in chain_creator.to_list()},
**{t: types.ToolNode for t in tool_creator.to_list()},
**{t: types.ToolkitNode for t in toolkits_creator.to_list()},
**{t: types.WrapperNode for t in wrapper_creator.to_list()},
**{t: types.LLMNode for t in llm_creator.to_list()},
**{t: types.MemoryNode for t in memory_creator.to_list()},
**{t: types.EmbeddingNode for t in embedding_creator.to_list()},
**{t: types.DocumentLoaderNode for t in documentloader_creator.to_list()},
**{t: types.TextSplitterNode for t in textsplitter_creator.to_list()},
**{t: types.OutputParserNode for t in output_parser_creator.to_list()},
**{t: types.CustomComponentNode for t in custom_component_creator.to_list()},
**{t: types.RetrieverNode for t in retriever_creator.to_list()},
}
lazy_load_node_dict = NodeTypesDict()
This change replaces the term vertex
with node
throughout the code to make it more intuitive and less confusing. Additionally, you should update the imports in src/backend/base/langflow/graph/__init__.py
to reflect this change:
from langflow.graph.edge.base import Edge
from langflow.graph.graph.base import Graph
from langflow.graph.node.base import Node
from langflow.graph.node.types import (
AgentNode,
ChainNode,
CustomComponentNode,
DocumentLoaderNode,
EmbeddingNode,
LLMNode,
MemoryNode,
PromptNode,
RetrieverNode,
TextSplitterNode,
ToolkitNode,
ToolNode,
VectorStoreNode,
WrapperNode,
)
__all__ = [
"Graph",
"Node",
"Edge",
"AgentNode",
"ChainNode",
"DocumentLoaderNode",
"EmbeddingNode",
"LLMNode",
"MemoryNode",
"PromptNode",
"TextSplitterNode",
"ToolNode",
"ToolkitNode",
"VectorStoreNode",
"WrapperNode",
"RetrieverNode",
"CustomComponentNode",
]
Additionally, update the Graph
class in src/backend/base/langflow/graph/graph/base.py
to replace vertex
with node
:
class Graph:
"""A class representing a graph of nodes and edges."""
def __init__(
self,
nodes: List[Dict],
edges: List[Dict[str, str]],
flow_id: Optional[str] = None,
user_id: Optional[str] = None,
) -> None:
"""
Initializes a new instance of the Graph class.
Args:
nodes (List[Dict]): A list of dictionaries representing the nodes of the graph.
edges (List[Dict[str, str]]): A list of dictionaries representing the edges of the graph.
flow_id (Optional[str], optional): The ID of the flow. Defaults to None.
"""
self._nodes = nodes
self._edges = edges
self.raw_graph_data = {"nodes": nodes, "edges": edges}
self._runs = 0
self._updates = 0
self.flow_id = flow_id
self.user_id = user_id
self._is_input_nodes: List[str] = []
self._is_output_nodes: List[str] = []
self._is_state_nodes: List[str] = []
self._has_session_id_nodes: List[str] = []
self._sorted_nodes_layers: List[List[str]] = []
self._run_id = ""
self.top_level_nodes = []
for node in self._nodes:
if node_id := node.get("id"):
self.top_level_nodes.append(node_id)
self._graph_data = process_flow(self.raw_graph_data)
self._nodes = self._graph_data["nodes"]
self._edges = self._graph_data["edges"]
self.inactivated_nodes: set = set()
self.activated_nodes: List[str] = []
self.nodes_layers: List[List[str]] = []
self.nodes_to_run: set[str] = set()
self.stop_node: Optional[str] = None
self.inactive_nodes: set = set()
self.edges: List[ContractEdge] = []
self.nodes: List[Node] = []
self.run_manager = RunnableNodesManager()
self._build_graph()
self.build_graph_maps(self.edges)
self.define_nodes_lists()
self.state_manager = GraphStateManager()
# ... (rest of the class implementation)
This ensures that the terminology is consistent and clear throughout the codebase [1][2][3][4][5].
To continue talking to Dosu, mention @dosu.
from langflow.
Related Issues (20)
- deprecated imports while running langflow HOT 1
- root:USER_AGENT environment variable warning with v1.0.0a46 during startup HOT 2
- [pre-release alpha bug] a46 with python 3.12.2 doesn't start up HOT 2
- Langflow show black screen on launch HOT 7
- feat: add Milvus components
- only getting first few letters of the output HOT 3
- [pre-release alpha bug] a46 with python 3.11.9 won't start HOT 5
- LANGFLOW black screen on launch HOT 2
- [Feature Request] Integration of Agent Protocol from AI-Engineer-Foundation into Langflow HOT 2
- JSON for Tool calling agent that invokes multiple Flows as Tool HOT 3
- Integrating Custom Callback to Output Agent Steps in Recode Format HOT 2
- Duplicate "session_id" in response of API on pre-release. HOT 6
- Error in the Code Export: Boolean values are in the incorrect syntax. 'false' should be changed to 'False', 'true' should be changed to 'True'. HOT 2
- No Response when running the Flow using cURL or Python API HOT 2
- TypeError: RedisCache.upsert() got an unexpected keyword argument 'lock' HOT 1
- Error building node TextLoader HOT 1
- sqlite3.OperationalError: table _alembic_tmp_flow already exists during Langflow startup HOT 1
- Testing alpha release with docker compose: required keyword-only argument: 'recursive_guard' HOT 2
- [Feature Request] Add support for `dimensions` parameter in embedding models
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from langflow.