You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove redundant ... from Field(..., description="...") in models.mdx structured output examples, aligning with Pydantic v2 style already used in structured-output.mdx. Also adds a <Note> in the Pydantic tab explaining required vs optional fields, and an inline sentence in the TypedDict tab explaining the ... sentinel in Annotated syntax.
All code examples have been tested and work correctly
I have used root relative paths for internal links
I have updated navigation in src/docs.json if needed
Additional notes
Field(description="...") without ... is equivalent in Pydantic v2 fields with no default remain required. LangChain >= 0.3 requires Pydantic v2, so no backwards-compatibility concern.
Hi pawel-twardziak:
I verified the new change introduced in documents. I see that simply passing description in Field function makes it a mandatory field to be returned by LLM.
Thanks for verifying Sangram Mohanty (@sangram11)! You're right — in Pydantic v2, Field(description="...") without the ... sentinel is equivalent; fields with no default are required by default. So this change is purely cosmetic/idiomatic.
Re: optional fields still being returned — that's expected LLM behavior. Most models will populate all fields present in the schema regardless of whether they're marked Optional. The Optional typing affects Pydantic validation (allowing None), not the model's generation behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
externalUser is not a member of langchain-ailangchainFor docs changes to LangChainosspythonFor content related to the Python version of LangChain projects
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove redundant
...fromField(..., description="...")inmodels.mdxstructured output examples, aligning with Pydantic v2 style already used instructured-output.mdx. Also adds a<Note>in the Pydantic tab explaining required vs optional fields, and an inline sentence in the TypedDict tab explaining the...sentinel inAnnotatedsyntax.Type of change
Type: Fix typo/bug/link/formatting
Related issues/PRs
Fixes #3098
Checklist
docs devsrc/docs.jsonif neededAdditional notes
Field(description="...")without...is equivalent in Pydantic v2 fields with no default remain required. LangChain >= 0.3 requires Pydantic v2, so no backwards-compatibility concern.