From 5640f84f547ade6d5a04aa0c9d878b5bee5ca670 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sun, 29 Dec 2024 17:52:48 +0400 Subject: [PATCH] fix: StructuredOutputComponent tool name generation for multiple=True mode (#5476) StructuredOutputComponent: fix tool name generation for multiple=True mode --- .../base/langflow/components/helpers/structured_output.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/base/langflow/components/helpers/structured_output.py b/src/backend/base/langflow/components/helpers/structured_output.py index f09dec332..95f0da21e 100644 --- a/src/backend/base/langflow/components/helpers/structured_output.py +++ b/src/backend/base/langflow/components/helpers/structured_output.py @@ -93,6 +93,8 @@ class StructuredOutputComponent(Component): ] def build_structured_output(self) -> Data: + schema_name = self.schema_name or "OutputModel" + if not hasattr(self.llm, "with_structured_output"): msg = "Language model does not support structured output." raise TypeError(msg) @@ -103,8 +105,8 @@ class StructuredOutputComponent(Component): output_model_ = build_model_from_schema(self.output_schema) if self.multiple: output_model = create_model( - self.schema_name, - objects=(list[output_model_], Field(description=f"A list of {self.schema_name}.")), # type: ignore[valid-type] + schema_name, + objects=(list[output_model_], Field(description=f"A list of {schema_name}.")), # type: ignore[valid-type] ) else: output_model = output_model_