diff --git a/src/backend/langflow/api/v1/callback.py b/src/backend/langflow/api/v1/callback.py
index 38737623c..b326311ac 100644
--- a/src/backend/langflow/api/v1/callback.py
+++ b/src/backend/langflow/api/v1/callback.py
@@ -33,9 +33,7 @@ class AsyncStreamingLLMCallbackHandleSIO(AsyncCallbackHandler):
resp = ChatResponse(message=token, type="stream", intermediate_steps="")
await self.socketio_service.emit_token(to=self.sid, data=resp.model_dump())
- async def on_tool_start(
- self, serialized: Dict[str, Any], input_str: str, **kwargs: Any
- ) -> Any:
+ async def on_tool_start(self, serialized: Dict[str, Any], input_str: str, **kwargs: Any) -> Any:
"""Run when tool starts running."""
resp = ChatResponse(
message="",
@@ -73,9 +71,7 @@ class AsyncStreamingLLMCallbackHandleSIO(AsyncCallbackHandler):
try:
# This is to emulate the stream of tokens
for resp in resps:
- await self.socketio_service.emit_token(
- to=self.sid, data=resp.model_dump()
- )
+ await self.socketio_service.emit_token(to=self.sid, data=resp.model_dump())
except Exception as exc:
logger.error(f"Error sending response: {exc}")
@@ -101,9 +97,7 @@ class AsyncStreamingLLMCallbackHandleSIO(AsyncCallbackHandler):
resp = PromptResponse(
prompt=text,
)
- await self.socketio_service.emit_message(
- to=self.sid, data=resp.model_dump()
- )
+ await self.socketio_service.emit_message(to=self.sid, data=resp.model_dump())
async def on_agent_action(self, action: AgentAction, **kwargs: Any):
log = f"Thought: {action.log}"
@@ -113,9 +107,7 @@ class AsyncStreamingLLMCallbackHandleSIO(AsyncCallbackHandler):
logs = log.split("\n")
for log in logs:
resp = ChatResponse(message="", type="stream", intermediate_steps=log)
- await self.socketio_service.emit_token(
- to=self.sid, data=resp.model_dump()
- )
+ await self.socketio_service.emit_token(to=self.sid, data=resp.model_dump())
else:
resp = ChatResponse(message="", type="stream", intermediate_steps=log)
await self.socketio_service.emit_token(to=self.sid, data=resp.model_dump())
diff --git a/src/backend/langflow/api/v1/chat.py b/src/backend/langflow/api/v1/chat.py
index 258277bca..af2e4b79b 100644
--- a/src/backend/langflow/api/v1/chat.py
+++ b/src/backend/langflow/api/v1/chat.py
@@ -99,12 +99,8 @@ async def build_vertex(
cache = chat_service.get_cache(flow_id)
if not cache:
# If there's no cache
- logger.warning(
- f"No cache found for {flow_id}. Building graph starting at {vertex_id}"
- )
- graph = build_and_cache_graph(
- flow_id=flow_id, session=next(get_session()), chat_service=chat_service
- )
+ logger.warning(f"No cache found for {flow_id}. Building graph starting at {vertex_id}")
+ graph = build_and_cache_graph(flow_id=flow_id, session=next(get_session()), chat_service=chat_service)
else:
graph = cache.get("result")
result_data_response = ResultDataResponse(results={})
@@ -197,9 +193,7 @@ async def build_vertex_stream(
else:
graph = cache.get("result")
else:
- session_data = await session_service.load_session(
- session_id, flow_id=flow_id
- )
+ session_data = await session_service.load_session(session_id, flow_id=flow_id)
graph, artifacts = session_data if session_data else (None, None)
if not graph:
raise ValueError(f"No graph found for {flow_id}.")
diff --git a/src/backend/langflow/components/vectorstores/base/model.py b/src/backend/langflow/components/vectorstores/base/model.py
index 2bc766b8b..74bf27025 100644
--- a/src/backend/langflow/components/vectorstores/base/model.py
+++ b/src/backend/langflow/components/vectorstores/base/model.py
@@ -36,14 +36,8 @@ class LCVectorStoreComponent(CustomComponent):
"""
docs: List[Document] = []
- if (
- input_value
- and isinstance(input_value, str)
- and hasattr(vector_store, "search")
- ):
- docs = vector_store.search(
- query=input_value, search_type=search_type.lower()
- )
+ if input_value and isinstance(input_value, str) and hasattr(vector_store, "search"):
+ docs = vector_store.search(query=input_value, search_type=search_type.lower())
else:
raise ValueError("Invalid inputs provided.")
return docs_to_records(docs)
diff --git a/src/backend/langflow/graph/graph/base.py b/src/backend/langflow/graph/graph/base.py
index 453076e1b..90eb932b5 100644
--- a/src/backend/langflow/graph/graph/base.py
+++ b/src/backend/langflow/graph/graph/base.py
@@ -86,9 +86,7 @@ class Graph:
if getattr(vertex, attribute):
getattr(self, f"_{attribute}_vertices").append(vertex.id)
- async def _run(
- self, inputs: Dict[str, str], stream: bool
- ) -> List[Optional["ResultData"]]:
+ async def _run(self, inputs: Dict[str, str], stream: bool) -> List[Optional["ResultData"]]:
"""Runs the graph with the given inputs."""
for vertex_id in self._is_input_vertices:
vertex = self.get_vertex(vertex_id)
@@ -111,9 +109,7 @@ class Graph:
outputs.append(vertex.result)
return outputs
- async def run(
- self, inputs: Dict[str, Union[str, list[str]]], stream: bool
- ) -> List[Optional["ResultData"]]:
+ async def run(self, inputs: Dict[str, Union[str, list[str]]], stream: bool) -> List[Optional["ResultData"]]:
"""Runs the graph with the given inputs."""
# inputs is {"message": "Hello, world!"}
@@ -125,9 +121,7 @@ class Graph:
if not isinstance(inputs_values, list):
inputs_values = [inputs_values]
for input_value in inputs_values:
- run_outputs = await self._run(
- {INPUT_FIELD_NAME: input_value}, stream=stream
- )
+ run_outputs = await self._run({INPUT_FIELD_NAME: input_value}, stream=stream)
logger.debug(f"Run outputs: {run_outputs}")
outputs.extend(run_outputs)
return outputs
@@ -167,9 +161,7 @@ class Graph:
def build_parent_child_map(self):
parent_child_map = defaultdict(list)
for vertex in self.vertices:
- parent_child_map[vertex.id] = [
- child.id for child in self.get_successors(vertex)
- ]
+ parent_child_map[vertex.id] = [child.id for child in self.get_successors(vertex)]
return parent_child_map
def increment_run_count(self):
@@ -344,11 +336,7 @@ class Graph:
return
self.vertices.remove(vertex)
self.vertex_map.pop(vertex_id)
- self.edges = [
- edge
- for edge in self.edges
- if edge.source_id != vertex_id and edge.target_id != vertex_id
- ]
+ self.edges = [edge for edge in self.edges if edge.source_id != vertex_id and edge.target_id != vertex_id]
def _build_vertex_params(self) -> None:
"""Identifies and handles the LLM vertex within the graph."""
@@ -369,9 +357,7 @@ class Graph:
return
for vertex in self.vertices:
if not self._validate_vertex(vertex):
- raise ValueError(
- f"{vertex.display_name} is not connected to any other components"
- )
+ raise ValueError(f"{vertex.display_name} is not connected to any other components")
def _validate_vertex(self, vertex: Vertex) -> bool:
"""Validates a vertex."""
@@ -428,9 +414,7 @@ class Graph:
tasks = []
for vertex_id in layer:
vertex = self.get_vertex(vertex_id)
- task = asyncio.create_task(
- vertex.build(), name=f"layer-{layer_index}-vertex-{vertex_id}"
- )
+ task = asyncio.create_task(vertex.build(), name=f"layer-{layer_index}-vertex-{vertex_id}")
tasks.append(task)
logger.debug(f"Running layer {layer_index} with {len(tasks)} tasks")
await self._execute_tasks(tasks)
@@ -469,9 +453,7 @@ class Graph:
def dfs(vertex):
if state[vertex] == 1:
# We have a cycle
- raise ValueError(
- "Graph contains a cycle, cannot perform topological sort"
- )
+ raise ValueError("Graph contains a cycle, cannot perform topological sort")
if state[vertex] == 0:
state[vertex] = 1
for edge in vertex.edges:
@@ -495,17 +477,11 @@ class Graph:
def get_predecessors(self, vertex):
"""Returns the predecessors of a vertex."""
- return [
- self.get_vertex(source_id)
- for source_id in self.predecessor_map.get(vertex.id, [])
- ]
+ return [self.get_vertex(source_id) for source_id in self.predecessor_map.get(vertex.id, [])]
def get_successors(self, vertex):
"""Returns the successors of a vertex."""
- return [
- self.get_vertex(target_id)
- for target_id in self.successor_map.get(vertex.id, [])
- ]
+ return [self.get_vertex(target_id) for target_id in self.successor_map.get(vertex.id, [])]
def get_vertex_neighbors(self, vertex: Vertex) -> Dict[Vertex, int]:
"""Returns the neighbors of a vertex."""
@@ -544,9 +520,7 @@ class Graph:
edges.append(ContractEdge(source, target, edge))
return edges
- def _get_vertex_class(
- self, node_type: str, node_base_type: str, node_id: str
- ) -> Type[Vertex]:
+ def _get_vertex_class(self, node_type: str, node_base_type: str, node_id: str) -> Type[Vertex]:
"""Returns the node class based on the node type."""
# First we check for the node_base_type
node_name = node_id.split("-")[0]
@@ -577,18 +551,14 @@ class Graph:
vertex_type: str = vertex_data["type"] # type: ignore
vertex_base_type: str = vertex_data["node"]["template"]["_type"] # type: ignore
- VertexClass = self._get_vertex_class(
- vertex_type, vertex_base_type, vertex_data["id"]
- )
+ VertexClass = self._get_vertex_class(vertex_type, vertex_base_type, vertex_data["id"])
vertex_instance = VertexClass(vertex, graph=self)
vertex_instance.set_top_level(self.top_level_vertices)
vertices.append(vertex_instance)
return vertices
- def get_children_by_vertex_type(
- self, vertex: Vertex, vertex_type: str
- ) -> List[Vertex]:
+ def get_children_by_vertex_type(self, vertex: Vertex, vertex_type: str) -> List[Vertex]:
"""Returns the children of a vertex based on the vertex type."""
children = []
vertex_types = [vertex.data["type"]]
@@ -600,9 +570,7 @@ class Graph:
def __repr__(self):
vertex_ids = [vertex.id for vertex in self.vertices]
- edges_repr = "\n".join(
- [f"{edge.source_id} --> {edge.target_id}" for edge in self.edges]
- )
+ edges_repr = "\n".join([f"{edge.source_id} --> {edge.target_id}" for edge in self.edges])
return f"Graph:\nNodes: {vertex_ids}\nConnections:\n{edges_repr}"
def sort_up_to_vertex(self, vertex_id: str) -> List[Vertex]:
@@ -633,9 +601,7 @@ class Graph:
"""Performs a layered topological sort of the vertices in the graph."""
vertices_ids = {vertex.id for vertex in vertices}
# Queue for vertices with no incoming edges
- queue = deque(
- vertex.id for vertex in vertices if self.in_degree_map[vertex.id] == 0
- )
+ queue = deque(vertex.id for vertex in vertices if self.in_degree_map[vertex.id] == 0)
layers: List[List[str]] = []
current_layer = 0
@@ -698,9 +664,7 @@ class Graph:
return refined_layers
- def sort_chat_inputs_first(
- self, vertices_layers: List[List[str]]
- ) -> List[List[str]]:
+ def sort_chat_inputs_first(self, vertices_layers: List[List[str]]) -> List[List[str]]:
chat_inputs_first = []
for layer in vertices_layers:
for vertex_id in layer:
@@ -729,15 +693,11 @@ class Graph:
self._sorted_vertices_layers = vertices_layers
return vertices_layers
- def sort_interface_components_first(
- self, vertices_layers: List[List[str]]
- ) -> List[List[str]]:
+ def sort_interface_components_first(self, vertices_layers: List[List[str]]) -> List[List[str]]:
"""Sorts the vertices in the graph so that vertices containing ChatInput or ChatOutput come first."""
def contains_interface_component(vertex):
- return any(
- component.value in vertex for component in InterfaceComponentTypes
- )
+ return any(component.value in vertex for component in InterfaceComponentTypes)
# Sort each inner list so that vertices containing ChatInput or ChatOutput come first
sorted_vertices = [
@@ -749,22 +709,16 @@ class Graph:
]
return sorted_vertices
- def sort_by_avg_build_time(
- self, vertices_layers: List[List[str]]
- ) -> List[List[str]]:
+ def sort_by_avg_build_time(self, vertices_layers: List[List[str]]) -> List[List[str]]:
"""Sorts the vertices in the graph so that vertices with the lowest average build time come first."""
def sort_layer_by_avg_build_time(vertices_ids: List[str]) -> List[str]:
"""Sorts the vertices in the graph so that vertices with the lowest average build time come first."""
if len(vertices_ids) == 1:
return vertices_ids
- vertices_ids.sort(
- key=lambda vertex_id: self.get_vertex(vertex_id).avg_build_time
- )
+ vertices_ids.sort(key=lambda vertex_id: self.get_vertex(vertex_id).avg_build_time)
return vertices_ids
- sorted_vertices = [
- sort_layer_by_avg_build_time(layer) for layer in vertices_layers
- ]
+ sorted_vertices = [sort_layer_by_avg_build_time(layer) for layer in vertices_layers]
return sorted_vertices
diff --git a/src/backend/langflow/graph/vertex/base.py b/src/backend/langflow/graph/vertex/base.py
index 6425f5e08..eaf6ba088 100644
--- a/src/backend/langflow/graph/vertex/base.py
+++ b/src/backend/langflow/graph/vertex/base.py
@@ -47,13 +47,8 @@ class Vertex:
self.will_stream = False
self.updated_raw_params = False
self.id: str = data["id"]
- self.is_input = any(
- input_component_name in self.id for input_component_name in INPUT_COMPONENTS
- )
- self.is_output = any(
- output_component_name in self.id
- for output_component_name in OUTPUT_COMPONENTS
- )
+ self.is_input = any(input_component_name in self.id for input_component_name in INPUT_COMPONENTS)
+ self.is_output = any(output_component_name in self.id for output_component_name in OUTPUT_COMPONENTS)
self.has_session_id = None
self._custom_component = None
self.has_external_input = False
@@ -97,17 +92,11 @@ class Vertex:
def set_state(self, state: str):
self.state = VertexStates[state]
- if (
- self.state == VertexStates.INACTIVE
- and self.graph.in_degree_map[self.id] < 2
- ):
+ if self.state == VertexStates.INACTIVE and self.graph.in_degree_map[self.id] < 2:
# If the vertex is inactive and has only one in degree
# it means that it is not a merge point in the graph
self.graph.inactive_vertices.add(self.id)
- elif (
- self.state == VertexStates.ACTIVE
- and self.id in self.graph.inactive_vertices
- ):
+ elif self.state == VertexStates.ACTIVE and self.id in self.graph.inactive_vertices:
self.graph.inactive_vertices.remove(self.id)
@property
@@ -124,9 +113,7 @@ class Vertex:
# If the Vertex.type is a power component
# then we need to return the built object
# instead of the result dict
- if self.is_interface_component and not isinstance(
- self._built_object, UnbuiltObject
- ):
+ if self.is_interface_component and not isinstance(self._built_object, UnbuiltObject):
result = self._built_object
# if it is not a dict or a string and hasattr model_dump then
# return the model_dump
@@ -136,11 +123,7 @@ class Vertex:
if isinstance(self._built_result, UnbuiltResult):
return {}
- return (
- self._built_result
- if isinstance(self._built_result, dict)
- else {"result": self._built_result}
- )
+ return self._built_result if isinstance(self._built_result, dict) else {"result": self._built_result}
def set_artifacts(self) -> None:
pass
@@ -206,31 +189,19 @@ class Vertex:
self.selected_output_type = self.data["node"].get("selected_output_type")
self.is_input = self.data["node"].get("is_input") or self.is_input
self.is_output = self.data["node"].get("is_output") or self.is_output
- template_dicts = {
- key: value
- for key, value in self.data["node"]["template"].items()
- if isinstance(value, dict)
- }
+ template_dicts = {key: value for key, value in self.data["node"]["template"].items() if isinstance(value, dict)}
self.has_session_id = "session_id" in template_dicts
self.required_inputs = [
- template_dicts[key]["type"]
- for key, value in template_dicts.items()
- if value["required"]
+ template_dicts[key]["type"] for key, value in template_dicts.items() if value["required"]
]
self.optional_inputs = [
- template_dicts[key]["type"]
- for key, value in template_dicts.items()
- if not value["required"]
+ template_dicts[key]["type"] for key, value in template_dicts.items() if not value["required"]
]
# Add the template_dicts[key]["input_types"] to the optional_inputs
self.optional_inputs.extend(
- [
- input_type
- for value in template_dicts.values()
- for input_type in value.get("input_types", [])
- ]
+ [input_type for value in template_dicts.values() for input_type in value.get("input_types", [])]
)
template_dict = self.data["node"]["template"]
@@ -277,11 +248,7 @@ class Vertex:
self.updated_raw_params = False
return
- template_dict = {
- key: value
- for key, value in self.data["node"]["template"].items()
- if isinstance(value, dict)
- }
+ template_dict = {key: value for key, value in self.data["node"]["template"].items() if isinstance(value, dict)}
params = {}
for edge in self.edges:
@@ -332,11 +299,7 @@ class Vertex:
# list of dicts, so we need to convert it to a dict
# before passing it to the build method
if isinstance(val, list):
- params[key] = {
- k: v
- for item in value.get("value", [])
- for k, v in item.items()
- }
+ params[key] = {k: v for item in value.get("value", []) for k, v in item.items()}
elif isinstance(val, dict):
params[key] = val
elif value.get("type") == "int" and val is not None:
@@ -429,9 +392,7 @@ class Vertex:
if isinstance(self._built_object, str):
self._built_result = self._built_object
- result = await generate_result(
- self._built_object, inputs, self.has_external_output, session_id
- )
+ result = await generate_result(self._built_object, inputs, self.has_external_output, session_id)
self._built_result = result
async def _build_each_node_in_params_dict(self, user_id=None):
@@ -461,9 +422,7 @@ class Vertex:
"""
return all(self._is_node(node) for node in value)
- async def get_result(
- self, requester: Optional["Vertex"] = None, user_id=None, timeout=None
- ) -> Any:
+ async def get_result(self, requester: Optional["Vertex"] = None, user_id=None, timeout=None) -> Any:
# PLEASE REVIEW THIS IF STATEMENT
# Check if the Vertex was built already
if self._built:
@@ -497,9 +456,7 @@ class Vertex:
self._extend_params_list_with_result(key, result)
self.params[key] = result
- async def _build_list_of_nodes_and_update_params(
- self, key, nodes: List["Vertex"], user_id=None
- ):
+ async def _build_list_of_nodes_and_update_params(self, key, nodes: List["Vertex"], user_id=None):
"""
Iterates over a list of nodes, builds each and updates the params dictionary.
"""
@@ -553,9 +510,7 @@ class Vertex:
except Exception as exc:
logger.exception(exc)
- raise ValueError(
- f"Error building node {self.display_name}: {str(exc)}"
- ) from exc
+ raise ValueError(f"Error building node {self.display_name}: {str(exc)}") from exc
def _update_built_object_and_artifacts(self, result):
"""
@@ -635,24 +590,16 @@ class Vertex:
return self._built_object
# Get the requester edge
- requester_edge = next(
- (edge for edge in self.edges if edge.target_id == requester.id), None
- )
+ requester_edge = next((edge for edge in self.edges if edge.target_id == requester.id), None)
# Return the result of the requester edge
- return (
- None
- if requester_edge is None
- else await requester_edge.get_result(source=self, target=requester)
- )
+ return None if requester_edge is None else await requester_edge.get_result(source=self, target=requester)
def add_edge(self, edge: "ContractEdge") -> None:
if edge not in self.edges:
self.edges.append(edge)
def __repr__(self) -> str:
- return (
- f"Vertex(display_name={self.display_name}, id={self.id}, data={self.data})"
- )
+ return f"Vertex(display_name={self.display_name}, id={self.id}, data={self.data})"
def __eq__(self, __o: object) -> bool:
try:
@@ -665,11 +612,7 @@ class Vertex:
def _built_object_repr(self):
# Add a message with an emoji, stars for sucess,
- return (
- "Built sucessfully ✨"
- if self._built_object is not None
- else "Failed to build 😵💫"
- )
+ return "Built sucessfully ✨" if self._built_object is not None else "Failed to build 😵💫"
class StatefulVertex(Vertex):
diff --git a/src/backend/langflow/interface/custom/utils.py b/src/backend/langflow/interface/custom/utils.py
index e1c8191ab..8fd231147 100644
--- a/src/backend/langflow/interface/custom/utils.py
+++ b/src/backend/langflow/interface/custom/utils.py
@@ -27,18 +27,14 @@ from langflow.utils import validate
from langflow.utils.util import get_base_classes
-def add_output_types(
- frontend_node: CustomComponentFrontendNode, return_types: List[str]
-):
+def add_output_types(frontend_node: CustomComponentFrontendNode, return_types: List[str]):
"""Add output types to the frontend node"""
for return_type in return_types:
if return_type is None:
raise HTTPException(
status_code=400,
detail={
- "error": (
- "Invalid return type. Please check your code and try again."
- ),
+ "error": ("Invalid return type. Please check your code and try again."),
"traceback": traceback.format_exc(),
},
)
@@ -69,18 +65,14 @@ def reorder_fields(frontend_node: CustomComponentFrontendNode, field_order: List
frontend_node.template.fields = reordered_fields
-def add_base_classes(
- frontend_node: CustomComponentFrontendNode, return_types: List[str]
-):
+def add_base_classes(frontend_node: CustomComponentFrontendNode, return_types: List[str]):
"""Add base classes to the frontend node"""
for return_type_instance in return_types:
if return_type_instance is None:
raise HTTPException(
status_code=400,
detail={
- "error": (
- "Invalid return type. Please check your code and try again."
- ),
+ "error": ("Invalid return type. Please check your code and try again."),
"traceback": traceback.format_exc(),
},
)
@@ -155,14 +147,10 @@ def add_new_custom_field(
# If options is a list, then it's a dropdown
# If options is None, then it's a list of strings
is_list = isinstance(field_config.get("options"), list)
- field_config["is_list"] = (
- is_list or field_config.get("is_list", False) or field_contains_list
- )
+ field_config["is_list"] = is_list or field_config.get("is_list", False) or field_contains_list
if "name" in field_config:
- warnings.warn(
- "The 'name' key in field_config is used to build the object and can't be changed."
- )
+ warnings.warn("The 'name' key in field_config is used to build the object and can't be changed.")
required = field_config.pop("required", field_required)
placeholder = field_config.pop("placeholder", "")
@@ -193,9 +181,7 @@ def add_extra_fields(frontend_node, field_config, function_args):
if "name" not in extra_field or extra_field["name"] == "self":
continue
- field_name, field_type, field_value, field_required = get_field_properties(
- extra_field
- )
+ field_name, field_type, field_value, field_required = get_field_properties(extra_field)
config = field_config.get(field_name, {})
frontend_node = add_new_custom_field(
frontend_node,
@@ -233,9 +219,7 @@ def run_build_config(
raise HTTPException(
status_code=400,
detail={
- "error": (
- "Invalid type convertion. Please check your code and try again."
- ),
+ "error": ("Invalid type convertion. Please check your code and try again."),
"traceback": traceback.format_exc(),
},
) from exc
@@ -263,9 +247,7 @@ def run_build_config(
raise HTTPException(
status_code=400,
detail={
- "error": (
- "Invalid type convertion. Please check your code and try again."
- ),
+ "error": ("Invalid type convertion. Please check your code and try again."),
"traceback": traceback.format_exc(),
},
) from exc
@@ -318,24 +300,16 @@ def build_custom_component_template(
try:
frontend_node = build_frontend_node(custom_component.template_config)
- field_config, custom_instance = run_build_config(
- custom_component, user_id=user_id, update_field=update_field
- )
+ field_config, custom_instance = run_build_config(custom_component, user_id=user_id, update_field=update_field)
entrypoint_args = custom_component.get_function_entrypoint_args
add_extra_fields(frontend_node, field_config, entrypoint_args)
- frontend_node = add_code_field(
- frontend_node, custom_component.code, field_config.get("code", {})
- )
+ frontend_node = add_code_field(frontend_node, custom_component.code, field_config.get("code", {}))
- add_base_classes(
- frontend_node, custom_component.get_function_entrypoint_return_type
- )
- add_output_types(
- frontend_node, custom_component.get_function_entrypoint_return_type
- )
+ add_base_classes(frontend_node, custom_component.get_function_entrypoint_return_type)
+ add_output_types(frontend_node, custom_component.get_function_entrypoint_return_type)
reorder_fields(frontend_node, custom_instance._get_field_order())
@@ -346,9 +320,7 @@ def build_custom_component_template(
raise HTTPException(
status_code=400,
detail={
- "error": (
- "Invalid type convertion. Please check your code and try again."
- ),
+ "error": ("Invalid type convertion. Please check your code and try again."),
"traceback": traceback.format_exc(),
},
) from exc
@@ -372,9 +344,7 @@ def build_custom_components(settings_service):
if not settings_service.settings.COMPONENTS_PATH:
return {}
- logger.info(
- f"Building custom components from {settings_service.settings.COMPONENTS_PATH}"
- )
+ logger.info(f"Building custom components from {settings_service.settings.COMPONENTS_PATH}")
custom_components_from_file = {}
processed_paths = set()
for path in settings_service.settings.COMPONENTS_PATH:
@@ -385,9 +355,7 @@ def build_custom_components(settings_service):
custom_component_dict = build_custom_component_list_from_path(path_str)
if custom_component_dict:
category = next(iter(custom_component_dict))
- logger.info(
- f"Loading {len(custom_component_dict[category])} component(s) from category {category}"
- )
+ logger.info(f"Loading {len(custom_component_dict[category])} component(s) from category {category}")
custom_components_from_file = merge_nested_dicts_with_renaming(
custom_components_from_file, custom_component_dict
)
diff --git a/src/backend/langflow/services/chat/utils.py b/src/backend/langflow/services/chat/utils.py
index f0e584f4c..0562b9df2 100644
--- a/src/backend/langflow/services/chat/utils.py
+++ b/src/backend/langflow/services/chat/utils.py
@@ -22,9 +22,7 @@ async def process_graph(
if build_result is None:
# Raise user facing error
- raise ValueError(
- "There was an error loading the langchain_object. Please, check all the nodes and try again."
- )
+ raise ValueError("There was an error loading the langchain_object. Please, check all the nodes and try again.")
# Generate result and thought
try:
@@ -50,7 +48,5 @@ async def process_graph(
raise e
-async def run_build_result(
- build_result: Any, chat_inputs: ChatMessage, client_id: str, session_id: str
-):
+async def run_build_result(build_result: Any, chat_inputs: ChatMessage, client_id: str, session_id: str):
return build_result(inputs=chat_inputs.message)
diff --git a/src/backend/langflow/services/utils.py b/src/backend/langflow/services/utils.py
index 34f1a042d..4c3533e97 100644
--- a/src/backend/langflow/services/utils.py
+++ b/src/backend/langflow/services/utils.py
@@ -92,16 +92,12 @@ def get_or_create_super_user(session: Session, username, password, is_default):
)
return None
else:
- logger.debug(
- "User with superuser credentials exists but is not a superuser."
- )
+ logger.debug("User with superuser credentials exists but is not a superuser.")
return None
if user:
if verify_password(password, user.password):
- raise ValueError(
- "User with superuser credentials exists but is not a superuser."
- )
+ raise ValueError("User with superuser credentials exists but is not a superuser.")
else:
raise ValueError("Incorrect superuser credentials")
@@ -130,21 +126,15 @@ def setup_superuser(settings_service, session: Session):
username = settings_service.auth_settings.SUPERUSER
password = settings_service.auth_settings.SUPERUSER_PASSWORD
- is_default = (username == DEFAULT_SUPERUSER) and (
- password == DEFAULT_SUPERUSER_PASSWORD
- )
+ is_default = (username == DEFAULT_SUPERUSER) and (password == DEFAULT_SUPERUSER_PASSWORD)
try:
- user = get_or_create_super_user(
- session=session, username=username, password=password, is_default=is_default
- )
+ user = get_or_create_super_user(session=session, username=username, password=password, is_default=is_default)
if user is not None:
logger.debug("Superuser created successfully.")
except Exception as exc:
logger.exception(exc)
- raise RuntimeError(
- "Could not create superuser. Please create a superuser manually."
- ) from exc
+ raise RuntimeError("Could not create superuser. Please create a superuser manually.") from exc
finally:
settings_service.auth_settings.reset_credentials()
@@ -158,9 +148,7 @@ def teardown_superuser(settings_service, session):
if not settings_service.auth_settings.AUTO_LOGIN:
try:
- logger.debug(
- "AUTO_LOGIN is set to False. Removing default superuser if exists."
- )
+ logger.debug("AUTO_LOGIN is set to False. Removing default superuser if exists.")
username = DEFAULT_SUPERUSER
from langflow.services.database.models.user.model import User
@@ -210,9 +198,7 @@ def initialize_session_service():
initialize_settings_service()
- service_manager.register_factory(
- cache_factory.CacheServiceFactory(), dependencies=[ServiceType.SETTINGS_SERVICE]
- )
+ service_manager.register_factory(cache_factory.CacheServiceFactory(), dependencies=[ServiceType.SETTINGS_SERVICE])
service_manager.register_factory(
session_service_factory.SessionServiceFactory(),
@@ -229,9 +215,7 @@ def initialize_services(fix_migration: bool = False, socketio_server=None):
service_manager.register_factory(factory, dependencies=dependencies)
except Exception as exc:
logger.exception(exc)
- raise RuntimeError(
- "Could not initialize services. Please check your settings."
- ) from exc
+ raise RuntimeError("Could not initialize services. Please check your settings.") from exc
# Test cache connection
service_manager.get(ServiceType.CACHE_SERVICE)
@@ -241,9 +225,7 @@ def initialize_services(fix_migration: bool = False, socketio_server=None):
except Exception as exc:
logger.error(exc)
raise exc
- setup_superuser(
- service_manager.get(ServiceType.SETTINGS_SERVICE), next(get_session())
- )
+ setup_superuser(service_manager.get(ServiceType.SETTINGS_SERVICE), next(get_session()))
try:
get_db_service().migrate_flows_if_auto_login()
except Exception as exc:
diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx
index 816e6be6a..ad76ff49a 100644
--- a/src/frontend/src/App.tsx
+++ b/src/frontend/src/App.tsx
@@ -18,11 +18,9 @@ import { getHealth } from "./controllers/API";
import Router from "./routes";
import useAlertStore from "./stores/alertStore";
import { useDarkStore } from "./stores/darkStore";
-import useFlowStore from "./stores/flowStore";
import useFlowsManagerStore from "./stores/flowsManagerStore";
import { useStoreStore } from "./stores/storeStore";
import { useTypesStore } from "./stores/typesStore";
-import { useShortcutsStore } from "./stores/shortcuts";
export default function App() {
const removeFromTempNotificationList = useAlertStore(
diff --git a/src/frontend/src/components/CrashErrorComponent/index.tsx b/src/frontend/src/components/CrashErrorComponent/index.tsx
index 0cf376195..57dc83d83 100644
--- a/src/frontend/src/components/CrashErrorComponent/index.tsx
+++ b/src/frontend/src/components/CrashErrorComponent/index.tsx
@@ -26,7 +26,7 @@ export default function CrashErrorComponent({
- Please report errors with detailed tracebacks on the{" "}
+ Please report errors with detailed tracebacks on the{" "}
{" "}
page.
- Thank you!
+ Thank you!