mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-31 18:38:48 +00:00
core: add error message for non-structured llm to StructuredPrompt (#22684)
previously was the blank `NotImplementedError` from `BaseLanguageModel.with_structured_output`
This commit is contained in:
@@ -118,10 +118,19 @@ class StructuredPrompt(ChatPromptTemplate):
|
|||||||
if isinstance(other, BaseLanguageModel) or hasattr(
|
if isinstance(other, BaseLanguageModel) or hasattr(
|
||||||
other, "with_structured_output"
|
other, "with_structured_output"
|
||||||
):
|
):
|
||||||
return RunnableSequence(self, other.with_structured_output(self.schema_))
|
try:
|
||||||
|
return RunnableSequence(
|
||||||
|
self, other.with_structured_output(self.schema_)
|
||||||
|
)
|
||||||
|
except NotImplementedError as e:
|
||||||
|
raise NotImplementedError(
|
||||||
|
"Structured prompts must be piped to a language model that "
|
||||||
|
"implements with_structured_output."
|
||||||
|
) from e
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
"Structured prompts need to be piped to a language model."
|
"Structured prompts must be piped to a language model that "
|
||||||
|
"implements with_structured_output."
|
||||||
)
|
)
|
||||||
|
|
||||||
def pipe(
|
def pipe(
|
||||||
|
Reference in New Issue
Block a user