ref: Add ruff rules for naming (N) (#4187)
Add ruff rules for naming (N)
This commit is contained in:
parent
f430f98c5c
commit
bdb4106ac0
35 changed files with 159 additions and 162 deletions
|
|
@ -34,7 +34,7 @@ from langflow.api.v1.schemas import (
|
|||
VerticesOrderResponse,
|
||||
)
|
||||
from langflow.events.event_manager import EventManager, create_default_event_manager
|
||||
from langflow.exceptions.component import ComponentBuildException
|
||||
from langflow.exceptions.component import ComponentBuildError
|
||||
from langflow.graph.graph.base import Graph
|
||||
from langflow.graph.utils import log_vertex_build
|
||||
from langflow.schema.schema import OutputValue
|
||||
|
|
@ -117,9 +117,9 @@ async def retrieve_vertices_order(
|
|||
background_tasks.add_task(
|
||||
telemetry_service.log_package_playground,
|
||||
PlaygroundPayload(
|
||||
playgroundSeconds=int(time.perf_counter() - start_time),
|
||||
playgroundComponentCount=components_count,
|
||||
playgroundSuccess=True,
|
||||
playground_seconds=int(time.perf_counter() - start_time),
|
||||
playground_component_count=components_count,
|
||||
playground_success=True,
|
||||
),
|
||||
)
|
||||
return VerticesOrderResponse(ids=graph.first_layer, run_id=graph.run_id, vertices_to_run=vertices_to_run)
|
||||
|
|
@ -127,10 +127,10 @@ async def retrieve_vertices_order(
|
|||
background_tasks.add_task(
|
||||
telemetry_service.log_package_playground,
|
||||
PlaygroundPayload(
|
||||
playgroundSeconds=int(time.perf_counter() - start_time),
|
||||
playgroundComponentCount=components_count,
|
||||
playgroundSuccess=False,
|
||||
playgroundErrorMessage=str(exc),
|
||||
playground_seconds=int(time.perf_counter() - start_time),
|
||||
playground_component_count=components_count,
|
||||
playground_success=False,
|
||||
playground_error_message=str(exc),
|
||||
),
|
||||
)
|
||||
if "stream or streaming set to True" in str(exc):
|
||||
|
|
@ -188,19 +188,19 @@ async def build_flow(
|
|||
background_tasks.add_task(
|
||||
telemetry_service.log_package_playground,
|
||||
PlaygroundPayload(
|
||||
playgroundSeconds=int(time.perf_counter() - start_time),
|
||||
playgroundComponentCount=components_count,
|
||||
playgroundSuccess=True,
|
||||
playground_seconds=int(time.perf_counter() - start_time),
|
||||
playground_component_count=components_count,
|
||||
playground_success=True,
|
||||
),
|
||||
)
|
||||
except Exception as exc:
|
||||
background_tasks.add_task(
|
||||
telemetry_service.log_package_playground,
|
||||
PlaygroundPayload(
|
||||
playgroundSeconds=int(time.perf_counter() - start_time),
|
||||
playgroundComponentCount=components_count,
|
||||
playgroundSuccess=False,
|
||||
playgroundErrorMessage=str(exc),
|
||||
playground_seconds=int(time.perf_counter() - start_time),
|
||||
playground_component_count=components_count,
|
||||
playground_success=False,
|
||||
playground_error_message=str(exc),
|
||||
),
|
||||
)
|
||||
if "stream or streaming set to True" in str(exc):
|
||||
|
|
@ -239,7 +239,7 @@ async def build_flow(
|
|||
|
||||
result_data_response = ResultDataResponse.model_validate(result_dict, from_attributes=True)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
if isinstance(exc, ComponentBuildException):
|
||||
if isinstance(exc, ComponentBuildError):
|
||||
params = exc.message
|
||||
tb = exc.formatted_traceback
|
||||
else:
|
||||
|
|
@ -301,20 +301,20 @@ async def build_flow(
|
|||
background_tasks.add_task(
|
||||
telemetry_service.log_package_component,
|
||||
ComponentPayload(
|
||||
componentName=vertex_id.split("-")[0],
|
||||
componentSeconds=int(time.perf_counter() - start_time),
|
||||
componentSuccess=valid,
|
||||
componentErrorMessage=error_message,
|
||||
component_name=vertex_id.split("-")[0],
|
||||
component_seconds=int(time.perf_counter() - start_time),
|
||||
component_success=valid,
|
||||
component_error_message=error_message,
|
||||
),
|
||||
)
|
||||
except Exception as exc:
|
||||
background_tasks.add_task(
|
||||
telemetry_service.log_package_component,
|
||||
ComponentPayload(
|
||||
componentName=vertex_id.split("-")[0],
|
||||
componentSeconds=int(time.perf_counter() - start_time),
|
||||
componentSuccess=False,
|
||||
componentErrorMessage=str(exc),
|
||||
component_name=vertex_id.split("-")[0],
|
||||
component_seconds=int(time.perf_counter() - start_time),
|
||||
component_success=False,
|
||||
component_error_message=str(exc),
|
||||
),
|
||||
)
|
||||
logger.exception("Error building Component")
|
||||
|
|
@ -524,7 +524,7 @@ async def build_vertex(
|
|||
top_level_vertices = graph.get_top_level_vertices(next_runnable_vertices)
|
||||
result_data_response = ResultDataResponse.model_validate(result_dict, from_attributes=True)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
if isinstance(exc, ComponentBuildException):
|
||||
if isinstance(exc, ComponentBuildError):
|
||||
params = exc.message
|
||||
tb = exc.formatted_traceback
|
||||
else:
|
||||
|
|
@ -590,20 +590,20 @@ async def build_vertex(
|
|||
background_tasks.add_task(
|
||||
telemetry_service.log_package_component,
|
||||
ComponentPayload(
|
||||
componentName=vertex_id.split("-")[0],
|
||||
componentSeconds=int(time.perf_counter() - start_time),
|
||||
componentSuccess=valid,
|
||||
componentErrorMessage=error_message,
|
||||
component_name=vertex_id.split("-")[0],
|
||||
component_seconds=int(time.perf_counter() - start_time),
|
||||
component_success=valid,
|
||||
component_error_message=error_message,
|
||||
),
|
||||
)
|
||||
except Exception as exc:
|
||||
background_tasks.add_task(
|
||||
telemetry_service.log_package_component,
|
||||
ComponentPayload(
|
||||
componentName=vertex_id.split("-")[0],
|
||||
componentSeconds=int(time.perf_counter() - start_time),
|
||||
componentSuccess=False,
|
||||
componentErrorMessage=str(exc),
|
||||
component_name=vertex_id.split("-")[0],
|
||||
component_seconds=int(time.perf_counter() - start_time),
|
||||
component_success=False,
|
||||
component_error_message=str(exc),
|
||||
),
|
||||
)
|
||||
logger.exception("Error building Component")
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ from langflow.api.v1.schemas import (
|
|||
)
|
||||
from langflow.custom.custom_component.component import Component
|
||||
from langflow.custom.utils import build_custom_component_template, get_instance_name
|
||||
from langflow.exceptions.api import APIException, InvalidChatInputException
|
||||
from langflow.exceptions.api import APIException, InvalidChatInputError
|
||||
from langflow.graph.graph.base import Graph
|
||||
from langflow.graph.schema import RunOutputs
|
||||
from langflow.helpers.flow import get_flow_by_id_or_endpoint_name
|
||||
|
|
@ -87,13 +87,13 @@ def validate_input_and_tweaks(input_request: SimplifiedAPIRequest):
|
|||
input_value_is_chat = input_request.input_value is not None and input_request.input_type == "chat"
|
||||
if has_input_value and input_value_is_chat:
|
||||
msg = "If you pass an input_value to the chat input, you cannot pass a tweak with the same name."
|
||||
raise InvalidChatInputException(msg)
|
||||
raise InvalidChatInputError(msg)
|
||||
elif ("Text Input" in key or "TextInput" in key) and isinstance(value, dict):
|
||||
has_input_value = value.get("input_value") is not None
|
||||
input_value_is_text = input_request.input_value is not None and input_request.input_type == "text"
|
||||
if has_input_value and input_value_is_text:
|
||||
msg = "If you pass an input_value to the text input, you cannot pass a tweak with the same name."
|
||||
raise InvalidChatInputException(msg)
|
||||
raise InvalidChatInputError(msg)
|
||||
|
||||
|
||||
async def simple_run_flow(
|
||||
|
|
@ -253,17 +253,19 @@ async def simplified_run_flow(
|
|||
end_time = time.perf_counter()
|
||||
background_tasks.add_task(
|
||||
telemetry_service.log_package_run,
|
||||
RunPayload(runIsWebhook=False, runSeconds=int(end_time - start_time), runSuccess=True, runErrorMessage=""),
|
||||
RunPayload(
|
||||
run_is_webhook=False, run_seconds=int(end_time - start_time), run_success=True, run_error_message=""
|
||||
),
|
||||
)
|
||||
|
||||
except ValueError as exc:
|
||||
background_tasks.add_task(
|
||||
telemetry_service.log_package_run,
|
||||
RunPayload(
|
||||
runIsWebhook=False,
|
||||
runSeconds=int(time.perf_counter() - start_time),
|
||||
runSuccess=False,
|
||||
runErrorMessage=str(exc),
|
||||
run_is_webhook=False,
|
||||
run_seconds=int(time.perf_counter() - start_time),
|
||||
run_success=False,
|
||||
run_error_message=str(exc),
|
||||
),
|
||||
)
|
||||
if "badly formed hexadecimal UUID string" in str(exc):
|
||||
|
|
@ -272,16 +274,16 @@ async def simplified_run_flow(
|
|||
if "not found" in str(exc):
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)) from exc
|
||||
raise APIException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, exception=exc, flow=flow) from exc
|
||||
except InvalidChatInputException as exc:
|
||||
except InvalidChatInputError as exc:
|
||||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(exc)) from exc
|
||||
except Exception as exc:
|
||||
background_tasks.add_task(
|
||||
telemetry_service.log_package_run,
|
||||
RunPayload(
|
||||
runIsWebhook=False,
|
||||
runSeconds=int(time.perf_counter() - start_time),
|
||||
runSuccess=False,
|
||||
runErrorMessage=str(exc),
|
||||
run_is_webhook=False,
|
||||
run_seconds=int(time.perf_counter() - start_time),
|
||||
run_success=False,
|
||||
run_error_message=str(exc),
|
||||
),
|
||||
)
|
||||
raise APIException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, exception=exc, flow=flow) from exc
|
||||
|
|
@ -355,10 +357,10 @@ async def webhook_run_flow(
|
|||
background_tasks.add_task(
|
||||
telemetry_service.log_package_run,
|
||||
RunPayload(
|
||||
runIsWebhook=True,
|
||||
runSeconds=int(time.perf_counter() - start_time),
|
||||
runSuccess=error_msg == "",
|
||||
runErrorMessage=error_msg,
|
||||
run_is_webhook=True,
|
||||
run_seconds=int(time.perf_counter() - start_time),
|
||||
run_success=error_msg == "",
|
||||
run_error_message=error_msg,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -548,7 +550,7 @@ async def create_upload_file(
|
|||
file_path = save_uploaded_file(file, folder_name=flow_id_str)
|
||||
|
||||
return UploadFileResponse(
|
||||
flowId=flow_id_str,
|
||||
flow_id=flow_id_str,
|
||||
file_path=file_path,
|
||||
)
|
||||
except Exception as exc:
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ async def upload_file(
|
|||
full_file_name = f"{timestamp}_{file_name}"
|
||||
folder = flow_id_str
|
||||
await storage_service.save_file(flow_id=folder, file_name=full_file_name, data=file_content)
|
||||
return UploadFileResponse(flowId=flow_id_str, file_path=f"{folder}/{full_file_name}")
|
||||
return UploadFileResponse(flow_id=flow_id_str, file_path=f"{folder}/{full_file_name}")
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e)) from e
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class ChatMessage(BaseModel):
|
|||
|
||||
is_bot: bool = False
|
||||
message: str | None | dict = None
|
||||
chatKey: str | None = None
|
||||
chat_key: str | None = Field(None, serialization_alias="chatKey")
|
||||
type: str = "human"
|
||||
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ class FlowListReadWithFolderName(BaseModel):
|
|||
|
||||
|
||||
class InitResponse(BaseModel):
|
||||
flowId: str
|
||||
flow_id: str = Field(serialization_alias="flowId")
|
||||
|
||||
|
||||
class BuiltResponse(BaseModel):
|
||||
|
|
@ -169,7 +169,7 @@ class BuiltResponse(BaseModel):
|
|||
class UploadFileResponse(BaseModel):
|
||||
"""Upload file response schema."""
|
||||
|
||||
flowId: str
|
||||
flow_id: str = Field(serialization_alias="flowId")
|
||||
file_path: Path
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from langflow.api.utils import check_langflow_version
|
|||
from langflow.services.auth import utils as auth_utils
|
||||
from langflow.services.database.models.user.model import User
|
||||
from langflow.services.deps import get_settings_service, get_store_service
|
||||
from langflow.services.store.exceptions import CustomException
|
||||
from langflow.services.store.exceptions import CustomError
|
||||
from langflow.services.store.schema import (
|
||||
CreateComponentResponse,
|
||||
DownloadComponentResponse,
|
||||
|
|
@ -131,7 +131,7 @@ async def get_components(
|
|||
limit=limit,
|
||||
store_api_key=store_api_key,
|
||||
)
|
||||
except CustomException as exc:
|
||||
except CustomError as exc:
|
||||
raise HTTPException(status_code=exc.status_code, detail=str(exc)) from exc
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
|
@ -145,7 +145,7 @@ async def download_component(
|
|||
):
|
||||
try:
|
||||
component = await store_service.download(store_api_key, component_id)
|
||||
except CustomException as exc:
|
||||
except CustomError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
|
@ -162,7 +162,7 @@ async def get_tags(
|
|||
):
|
||||
try:
|
||||
return await store_service.get_tags()
|
||||
except CustomException as exc:
|
||||
except CustomError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
|
@ -175,7 +175,7 @@ async def get_list_of_components_liked_by_user(
|
|||
):
|
||||
try:
|
||||
return await store_service.get_user_likes(store_api_key)
|
||||
except CustomException as exc:
|
||||
except CustomError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
|
@ -192,7 +192,7 @@ async def like_component(
|
|||
likes_count = await store_service.get_component_likes_count(str(component_id), store_api_key)
|
||||
|
||||
return UsersLikesResponse(likes_count=likes_count, liked_by_user=result)
|
||||
except CustomException as exc:
|
||||
except CustomError as exc:
|
||||
raise HTTPException(status_code=exc.status_code, detail=str(exc)) from exc
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ class FirecrawlCrawlApi(CustomComponent):
|
|||
api_key: str,
|
||||
url: str,
|
||||
timeout: int = 30000,
|
||||
crawlerOptions: Data | None = None,
|
||||
pageOptions: Data | None = None,
|
||||
crawlerOptions: Data | None = None, # noqa: N803
|
||||
pageOptions: Data | None = None, # noqa: N803
|
||||
idempotency_key: str | None = None,
|
||||
) -> Data:
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ class FirecrawlScrapeApi(CustomComponent):
|
|||
api_key: str,
|
||||
url: str,
|
||||
timeout: int = 10000,
|
||||
pageOptions: Data | None = None,
|
||||
extractorOptions: Data | None = None,
|
||||
pageOptions: Data | None = None, # noqa: N803
|
||||
extractorOptions: Data | None = None, # noqa: N803
|
||||
) -> Data:
|
||||
try:
|
||||
from firecrawl.firecrawl import FirecrawlApp
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class AstraDBCQLToolComponent(LCToolComponent):
|
|||
|
||||
def astra_rest(self, args):
|
||||
headers = {"Accept": "application/json", "X-Cassandra-Token": f"{self.token}"}
|
||||
ASTRA_URL = f"{self.api_endpoint}/api/rest/v2/keyspaces/{self.keyspace}/{self.table_name}/"
|
||||
astra_url = f"{self.api_endpoint}/api/rest/v2/keyspaces/{self.keyspace}/{self.table_name}/"
|
||||
key = []
|
||||
# Partition keys are mandatory
|
||||
for k in self.partition_keys:
|
||||
|
|
@ -108,7 +108,7 @@ class AstraDBCQLToolComponent(LCToolComponent):
|
|||
elif self.static_filters[k] is not None:
|
||||
key.append(self.static_filters[k])
|
||||
|
||||
url = f'{ASTRA_URL}{"/".join(key)}?page-size={self.number_of_results}'
|
||||
url = f'{astra_url}{"/".join(key)}?page-size={self.number_of_results}'
|
||||
|
||||
if self.projection_fields != "*":
|
||||
url += f'&fields={urllib.parse.quote(self.projection_fields.replace(" ","")) }'
|
||||
|
|
|
|||
|
|
@ -198,13 +198,13 @@ class PythonCodeStructuredTool(LCToolComponent):
|
|||
if "temp_annotation_type" in _globals:
|
||||
_globals.pop("temp_annotation_type")
|
||||
|
||||
PythonCodeToolSchema = None
|
||||
python_code_tool_schema = None
|
||||
if schema_fields:
|
||||
PythonCodeToolSchema = create_model("PythonCodeToolSchema", **schema_fields)
|
||||
python_code_tool_schema = create_model("PythonCodeToolSchema", **schema_fields)
|
||||
|
||||
return StructuredTool.from_function(
|
||||
func=_local[self.tool_function].run,
|
||||
args_schema=PythonCodeToolSchema,
|
||||
args_schema=python_code_tool_schema,
|
||||
name=self.tool_name,
|
||||
description=self.tool_description,
|
||||
return_direct=self.return_direct,
|
||||
|
|
|
|||
|
|
@ -129,11 +129,11 @@ class SearXNGToolComponent(LCToolComponent):
|
|||
"categories": (list[str], Field(default=[], description="The categories to search in.")),
|
||||
}
|
||||
|
||||
SearxSearchSchema = create_model("SearxSearchSchema", **schema_fields)
|
||||
searx_search_schema = create_model("SearxSearchSchema", **schema_fields)
|
||||
|
||||
return StructuredTool.from_function(
|
||||
func=_local["SearxSearch"].search,
|
||||
args_schema=SearxSearchSchema,
|
||||
args_schema=searx_search_schema,
|
||||
name="searxng_search_tool",
|
||||
description="A tool that searches for tools using SearXNG.\nThe available categories are: "
|
||||
+ ", ".join(self.categories),
|
||||
|
|
|
|||
|
|
@ -801,8 +801,8 @@ class Component(CustomComponent):
|
|||
return Input(**kwargs)
|
||||
|
||||
def to_toolkit(self) -> list[Tool]:
|
||||
ComponentToolkit = _get_component_toolkit()
|
||||
return ComponentToolkit(component=self).get_tools()
|
||||
component_toolkit = _get_component_toolkit()
|
||||
return component_toolkit(component=self).get_tools()
|
||||
|
||||
def get_project_name(self):
|
||||
if hasattr(self, "_tracing_service") and self._tracing_service:
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
import ast
|
||||
|
||||
from typing_extensions import override
|
||||
|
||||
|
||||
class RequiredInputsVisitor(ast.NodeVisitor):
|
||||
def __init__(self, inputs):
|
||||
self.inputs = inputs
|
||||
self.required_inputs = set()
|
||||
|
||||
@override
|
||||
def visit_Attribute(self, node):
|
||||
if isinstance(node.value, ast.Name) and node.value.id == "self" and node.attr in self.inputs:
|
||||
self.required_inputs.add(node.attr)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from langflow.services.database.models.flow.model import Flow
|
|||
from langflow.services.database.models.flow.utils import get_outdated_components
|
||||
|
||||
|
||||
class InvalidChatInputException(Exception):
|
||||
class InvalidChatInputError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Create an exception class that receives the message and the formatted traceback
|
||||
class ComponentBuildException(Exception):
|
||||
class ComponentBuildError(Exception):
|
||||
def __init__(self, message: str, formatted_traceback: str):
|
||||
self.message = message
|
||||
self.formatted_traceback = formatted_traceback
|
||||
|
|
|
|||
|
|
@ -138,22 +138,22 @@ def draw_graph(vertexes, edges, *, return_ascii=True):
|
|||
"""Build a DAG and draw it in ASCII."""
|
||||
sug = build_sugiyama_layout(vertexes, edges)
|
||||
|
||||
Xs = []
|
||||
Ys = []
|
||||
xlist = []
|
||||
ylist = []
|
||||
|
||||
for vertex in sug.g.sV:
|
||||
Xs.extend([vertex.view.xy[0] - vertex.view.w / 2.0, vertex.view.xy[0] + vertex.view.w / 2.0])
|
||||
Ys.extend([vertex.view.xy[1], vertex.view.xy[1] + vertex.view.h])
|
||||
xlist.extend([vertex.view.xy[0] - vertex.view.w / 2.0, vertex.view.xy[0] + vertex.view.w / 2.0])
|
||||
ylist.extend([vertex.view.xy[1], vertex.view.xy[1] + vertex.view.h])
|
||||
|
||||
for edge in sug.g.sE:
|
||||
for x, y in edge.view._pts:
|
||||
Xs.append(x)
|
||||
Ys.append(y)
|
||||
xlist.append(x)
|
||||
ylist.append(y)
|
||||
|
||||
minx = min(Xs)
|
||||
miny = min(Ys)
|
||||
maxx = max(Xs)
|
||||
maxy = max(Ys)
|
||||
minx = min(xlist)
|
||||
miny = min(ylist)
|
||||
maxx = max(xlist)
|
||||
maxy = max(ylist)
|
||||
|
||||
canvas_cols = int(math.ceil(maxx - minx)) + 1
|
||||
canvas_lines = int(round(maxy - miny))
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from typing import TYPE_CHECKING, Any, cast
|
|||
import nest_asyncio
|
||||
from loguru import logger
|
||||
|
||||
from langflow.exceptions.component import ComponentBuildException
|
||||
from langflow.exceptions.component import ComponentBuildError
|
||||
from langflow.graph.edge.base import CycleEdge, Edge
|
||||
from langflow.graph.graph.constants import Finish, lazy_load_vertex_dict
|
||||
from langflow.graph.graph.runnable_vertices_manager import RunnableVerticesManager
|
||||
|
|
@ -1394,7 +1394,7 @@ class Graph:
|
|||
await set_cache(key=vertex.id, data=vertex_dict)
|
||||
|
||||
except Exception as exc:
|
||||
if not isinstance(exc, ComponentBuildException):
|
||||
if not isinstance(exc, ComponentBuildError):
|
||||
logger.exception("Error building Component")
|
||||
raise
|
||||
|
||||
|
|
@ -1699,13 +1699,13 @@ class Graph:
|
|||
return InterfaceVertex
|
||||
if node_name in {"SharedState", "Notify", "Listen"}:
|
||||
return StateVertex
|
||||
if node_base_type in lazy_load_vertex_dict.VERTEX_TYPE_MAP:
|
||||
return lazy_load_vertex_dict.VERTEX_TYPE_MAP[node_base_type]
|
||||
if node_name in lazy_load_vertex_dict.VERTEX_TYPE_MAP:
|
||||
return lazy_load_vertex_dict.VERTEX_TYPE_MAP[node_name]
|
||||
if node_base_type in lazy_load_vertex_dict.vertex_type_map:
|
||||
return lazy_load_vertex_dict.vertex_type_map[node_base_type]
|
||||
if node_name in lazy_load_vertex_dict.vertex_type_map:
|
||||
return lazy_load_vertex_dict.vertex_type_map[node_name]
|
||||
|
||||
if node_type in lazy_load_vertex_dict.VERTEX_TYPE_MAP:
|
||||
return lazy_load_vertex_dict.VERTEX_TYPE_MAP[node_type]
|
||||
if node_type in lazy_load_vertex_dict.vertex_type_map:
|
||||
return lazy_load_vertex_dict.vertex_type_map[node_type]
|
||||
return Vertex
|
||||
|
||||
def _build_vertices(self) -> list[Vertex]:
|
||||
|
|
@ -1730,9 +1730,9 @@ class Graph:
|
|||
msg = f"Vertex data for {vertex_data['display_name']} does not contain an id"
|
||||
raise ValueError(msg)
|
||||
|
||||
VertexClass = self._get_vertex_class(vertex_type, vertex_base_type, vertex_data["id"])
|
||||
vertex_class = self._get_vertex_class(vertex_type, vertex_base_type, vertex_data["id"])
|
||||
|
||||
vertex_instance = VertexClass(frontend_data, graph=self)
|
||||
vertex_instance = vertex_class(frontend_data, graph=self)
|
||||
vertex_instance.set_top_level(self.top_level_vertices)
|
||||
return vertex_instance
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class VertexTypesDict(LazyLoadDictBase):
|
|||
self._types = _import_vertex_types
|
||||
|
||||
@property
|
||||
def VERTEX_TYPE_MAP(self):
|
||||
def vertex_type_map(self):
|
||||
return self.all_types_dict
|
||||
|
||||
def _build_dict(self):
|
||||
|
|
|
|||
|
|
@ -48,8 +48,6 @@ class ResultData(BaseModel):
|
|||
|
||||
|
||||
class InterfaceComponentTypes(str, Enum, metaclass=ContainsEnumMeta):
|
||||
# ChatInput and ChatOutput are the only ones that are
|
||||
# power components
|
||||
ChatInput = "ChatInput"
|
||||
ChatOutput = "ChatOutput"
|
||||
TextInput = "TextInput"
|
||||
|
|
@ -57,14 +55,6 @@ class InterfaceComponentTypes(str, Enum, metaclass=ContainsEnumMeta):
|
|||
DataOutput = "DataOutput"
|
||||
WebhookInput = "Webhook"
|
||||
|
||||
def __contains__(cls, item):
|
||||
try:
|
||||
cls(item)
|
||||
except ValueError:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
CHAT_COMPONENTS = [InterfaceComponentTypes.ChatInput, InterfaceComponentTypes.ChatOutput]
|
||||
RECORDS_COMPONENTS = [InterfaceComponentTypes.DataOutput]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from typing import TYPE_CHECKING, Any
|
|||
import pandas as pd
|
||||
from loguru import logger
|
||||
|
||||
from langflow.exceptions.component import ComponentBuildException
|
||||
from langflow.exceptions.component import ComponentBuildError
|
||||
from langflow.graph.schema import INPUT_COMPONENTS, OUTPUT_COMPONENTS, InterfaceComponentTypes, ResultData
|
||||
from langflow.graph.utils import UnbuiltObject, UnbuiltResult, log_transaction
|
||||
from langflow.interface import initialize
|
||||
|
|
@ -256,7 +256,7 @@ class Vertex:
|
|||
)
|
||||
|
||||
if self.base_type is None:
|
||||
for base_type, value in lazy_load_dict.ALL_TYPES_DICT.items():
|
||||
for base_type, value in lazy_load_dict.all_types_dict.items():
|
||||
if self.vertex_type in value:
|
||||
self.base_type = base_type
|
||||
break
|
||||
|
|
@ -720,7 +720,7 @@ class Vertex:
|
|||
tb = traceback.format_exc()
|
||||
logger.exception(exc)
|
||||
msg = f"Error building Component {self.display_name}: \n\n{exc}"
|
||||
raise ComponentBuildException(msg, tb) from exc
|
||||
raise ComponentBuildError(msg, tb) from exc
|
||||
|
||||
def _update_built_object_and_artifacts(self, result: Any | tuple[Any, dict] | tuple[Component, Any, dict]):
|
||||
"""Updates the built object and its artifacts."""
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
class NoComponentInstance(Exception):
|
||||
class NoComponentInstanceError(Exception):
|
||||
def __init__(self, vertex_id: str):
|
||||
message = f"Vertex {vertex_id} does not have a component instance."
|
||||
super().__init__(message)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue