fix: StructuredOutputComponent tool name generation for multiple=True mode (#5476)
StructuredOutputComponent: fix tool name generation for multiple=True mode
This commit is contained in:
parent
e91bcc2520
commit
5640f84f54
1 changed files with 4 additions and 2 deletions
|
|
@ -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_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue