Skip to content

Commit

Permalink
Merge branch 'main' into ruff-rules-preview-2
Browse files Browse the repository at this point in the history
  • Loading branch information
cbornet authored Oct 14, 2024
2 parents e95ba18 + ba3bd8a commit e5478d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/backend/base/langflow/components/prototypes/FlowTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def update_build_config(self, build_config: dotdict, field_value: Any, field_nam
name="flow_name", display_name="Flow Name", info="The name of the flow to run.", refresh_button=True
),
StrInput(
name="name",
name="tool_name",
display_name="Name",
info="The name of the tool.",
),
StrInput(
name="description",
name="tool_description",
display_name="Description",
info="The description of the tool.",
),
Expand Down Expand Up @@ -89,8 +89,8 @@ def build_tool(self) -> Tool:
logger.opt(exception=True).warning("Failed to set run_id")
inputs = get_flow_inputs(graph)
tool = FlowTool(
name=self.name,
description=self.description,
name=self.tool_name,
description=self.tool_description,
graph=graph,
return_direct=self.return_direct,
inputs=inputs,
Expand Down
9 changes: 6 additions & 3 deletions src/backend/base/langflow/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from loguru import logger
from pydantic import BaseModel
from pydantic.v1 import BaseModel as BaseModelV1
from typing_extensions import TypedDict

from langflow.schema import Data
Expand Down Expand Up @@ -116,11 +117,13 @@ def build_output_logs(vertex, result) -> dict:

def recursive_serialize_or_str(obj):
try:
if isinstance(obj, str):
return obj
if isinstance(obj, dict):
return {k: recursive_serialize_or_str(v) for k, v in obj.items()}
if isinstance(obj, list):
return [recursive_serialize_or_str(v) for v in obj]
if isinstance(obj, BaseModel):
if isinstance(obj, BaseModel | BaseModelV1):
if hasattr(obj, "model_dump"):
obj_dict = obj.model_dump()
elif hasattr(obj, "dict"):
Expand All @@ -138,10 +141,10 @@ def recursive_serialize_or_str(obj):
return {k: recursive_serialize_or_str(v) for k, v in obj.dict().items()}
if hasattr(obj, "model_dump"):
return {k: recursive_serialize_or_str(v) for k, v in obj.model_dump().items()}
if issubclass(obj, BaseModel):
if isinstance(obj, type) and issubclass(obj, BaseModel):
# This a type BaseModel and not an instance of it
return repr(obj)
return str(obj)
except Exception: # noqa: BLE001
logger.opt(exception=True).debug(f"Cannot serialize object {obj}")
logger.debug(f"Cannot serialize object {obj}")
return str(obj)

0 comments on commit e5478d2

Please sign in to comment.