Skip to content

schema_json fail with Pydantic BaseModel in langchain-core==0.3.0.dev4 #26250

Closed as not planned
@liuhetian

Description

@liuhetian

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

from langchain_openai import ChatOpenAI
model_chat = ChatOpenAI(api_key='foo')
print(model_chat.get_output_schema().schema_json()[:5])  # ok 

from pydantic import BaseModel
from typing import Any
class Foo(BaseModel):
    bar: Any
model_chat.with_structured_output(Foo, method='json_schema', strict=True).get_output_schema().schema_json()  
# PydanticUserError

Error Message and Stack Trace (if applicable)

PydanticUserError: _oai_structured_outputs_parser_output is not fully defined; you should define PydanticBaseModel, then call _oai_structured_outputs_parser_output.model_rebuild().

Description

meet this question when using langserve add_routes(app, mychain, path='/faq')

System Info

langchain-core==0.3.0.dev4
langchain-openai==0.2.0.dev2

pydantic==2.9.1
pydantic-extra-types==2.5.0
pydantic-settings==2.2.1
pydantic_core==2.23.3

python=3.12

Metadata

Metadata

Assignees

Labels

investigateFlagged for investigation.todoⱭ: coreRelated to langchain-core🤖:bugRelated to a bug, vulnerability, unexpected error with an existing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions