mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-31 10:23:18 +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(
|
||||
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:
|
||||
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(
|
||||
|
Reference in New Issue
Block a user