LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmith_openapi_client_modelsBaseModelmodel_dump
Method●Since v0.8

model_dump

Copy
model_dump(
  self,
  *,
  mode: Literal['json', 'python'] | str = 'python',
View source on GitHub
include
:
IncEx
|
None
=
None
,
exclude
:
IncEx
|
None
=
None
,
context
:
Any
|
None
=
None
,
by_alias
:
bool
|
None
=
None
,
exclude_unset
:
bool
=
False
,
exclude_defaults
:
bool
=
False
,
exclude_none
:
bool
=
False
,
exclude_computed_fields
:
bool
=
False
,
round_trip
:
bool
=
False
,
warnings
:
bool
|
Literal
[
'none'
,
'warn'
,
'error'
]
=
True
,
fallback
:
Callable
[
[
Any
]
,
Any
]
|
None
=
None
,
serialize_as_any
:
bool
=
False
)
->
dict
[
str
,
Any
]

Parameters

NameTypeDescription
modeLiteral['json', 'python'] | str
Default:'python'

The mode in which to_python should run. If mode is 'json', the output will only contain JSON serializable types. If mode is 'python', the output may contain non-JSON-serializable Python objects.

includeIncEx | None
Default:None

A set of fields to include in the output.

excludeIncEx | None
Default:None
contextAny | None
Default:None
by_aliasbool | None
Default:None
exclude_unsetbool
Default:False
exclude_defaultsbool
Default:False
exclude_nonebool
Default:False
exclude_computed_fieldsbool
Default:False
round_tripbool
Default:False
warningsbool | Literal['none', 'warn', 'error']
Default:True
fallbackCallable[[Any], Any] | None
Default:None
serialize_as_anybool
Default:False

Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

A set of fields to exclude from the output.

Additional context to pass to the serializer.

Whether to use the field's alias in the dictionary key if defined.

Whether to exclude fields that have not been explicitly set.

Whether to exclude fields that are set to their default value.

Whether to exclude fields that have a value of None.

Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

If True, dumped values should be valid as input for non-idempotent types such as Json[T].

How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors, "error" raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

Whether to serialize fields with duck-typing serialization behavior.