standard-tests[patch]: use has_structured_output property to engage structured output tests (#29635)

Motivation: dedicated structured output features are becoming more
common, such that integrations can support structured output without
supporting tool calling.

Here we make two changes:

1. Update the `has_structured_output` method to default to True if a
model supports tool calling (in addition to defaulting to True if
`with_structured_output` is overridden).
2. Update structured output tests to engage if `has_structured_output`
is True.
This commit is contained in:
ccurme
2025-02-06 13:09:06 -05:00
committed by GitHub
parent db8201d4da
commit 9da06e6e94
2 changed files with 40 additions and 28 deletions

View File

@@ -133,7 +133,7 @@ class ChatModelTests(BaseStandardTests):
return (
self.chat_model_class.with_structured_output
is not BaseChatModel.with_structured_output
)
) or self.has_tool_calling
@property
def structured_output_kwargs(self) -> dict:
@@ -293,9 +293,9 @@ class ChatModelUnitTests(ChatModelTests):
Boolean property indicating whether the chat model supports structured
output.
By default, this is determined by whether the chat model's
``with_structured_output`` method is overridden. If the base implementation is
intended to be used, this method should be overridden.
By default, this is determined by whether the chat model overrides the
``with_structured_output`` or ``bind_tools`` methods. If the base
implementations are intended to be used, this method should be overridden.
See: https://python.langchain.com/docs/concepts/structured_outputs/