Test structured output using pydantic.v1.BaseModel.
Verify we can generate structured output using pydantic.v1.BaseModel.
pydantic.v1.BaseModel is available in the Pydantic 2 package.
This test is optional and should be skipped if the model does not support structured output (see configuration below).
To disable structured output tests, set has_structured_output to False
in your test class:
class TestMyChatModelIntegration(ChatModelIntegrationTests):
@property
def has_structured_output(self) -> bool:
return False
By default, has_structured_output is True if a model overrides the
with_structured_output or bind_tools methods.
If this test fails, ensure that the model's bind_tools method
properly handles both JSON Schema and Pydantic V1 models.
langchain_core implements a utility function.
that will accommodate most formats.
See example implementation.
of with_structured_output.
test_structured_output_pydantic_2_v1(
self,
model: BaseChatModel,
) -> None