core[minor]: BaseChatModel with_structured_output implementation (#22859)

This commit is contained in:
Brace Sproul
2024-06-21 08:14:03 -07:00
committed by GitHub
parent 360a70c8a8
commit abe7566d7d
4 changed files with 142 additions and 29 deletions

View File

@@ -334,7 +334,7 @@ class FakeStructuredOutputModel(BaseChatModel):
def with_structured_output(
self, schema: Union[Dict, Type[BaseModel]], **kwargs: Any
) -> Runnable[LanguageModelInput, Union[Dict, BaseModel]]:
return self | (lambda x: {"foo": self.foo})
return RunnableLambda(lambda x: {"foo": self.foo})
@property
def _llm_type(self) -> str:
@@ -388,6 +388,3 @@ def test_fallbacks_getattr_runnable_output() -> None:
for fallback in llm_with_fallbacks_with_tools.fallbacks
)
assert llm_with_fallbacks_with_tools.runnable.kwargs["tools"] == []
with pytest.raises(NotImplementedError):
llm_with_fallbacks.with_structured_output({})