EmbeddedIPythonCodeExecutorpython -m ipykernel install --user --name \{kernel_name}
where kernel_name
is the name of the kernel to install.ValidationError
][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.self
is explicitly positional-only to allow self
as a field name.
Parameters:
Name | Description |
---|---|
**kwargs | Type: Any |
None
if config.extra
is not set to "allow"
.
Name | Description |
---|---|
**values | Type: Any |
model_copy
instead.include
or exclude
, use:
Name | Description |
---|---|
include | Optional set or mapping specifying which fields to include in the copied model. Type: AbstractSetIntStr | MappingIntStrAny | None Default: None |
exclude | Optional set or mapping specifying which fields to exclude in the copied model. Type: AbstractSetIntStr | MappingIntStrAny | None Default: None |
update | Optional dictionary of field-value pairs to override field values in the copied model. Type: Dict[str, Any] | None Default: None |
deep | If True, the values of fields that are Pydantic models will be deep-copied. Type: bool Default: False |
Type | Description |
---|---|
Self | A copy of the model with included, excluded and updated fields as specified. |
Name | Description |
---|---|
include | Type: IncEx | None Default: None |
exclude | Type: IncEx | None Default: None |
by_alias | Type: bool Default: False |
exclude_unset | Type: bool Default: False |
exclude_defaults | Type: bool Default: False |
exclude_none | Type: bool Default: False |
Name | Description |
---|---|
code_blocks | A list of code blocks to execute. Type: list[CodeBlock] |
Type | Description |
---|---|
autogen.coding.base.IPythonCodeResult | IPythonCodeResult: The result of the code execution. |
Name | Description |
---|---|
obj | Type: Any |
Name | Description |
---|---|
include | Type: IncEx | None Default: None |
exclude | Type: IncEx | None Default: None |
by_alias | Type: bool Default: False |
exclude_unset | Type: bool Default: False |
exclude_defaults | Type: bool Default: False |
exclude_none | Type: bool Default: False |
encoder | Type: Callable[[Any], Any] | None Default: PydanticUndefined |
models_as_dict | Type: bool Default: PydanticUndefined |
**dumps_kwargs | Type: Any |
Model
class with validated data.__dict__
and __pydantic_fields_set__
from trusted or pre-validated data.model_construct()
generally respects the model_config.extra
setting on the provided model.model_config.extra == 'allow'
, then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__
fields. If model_config.extra == 'ignore'
(the default), then all extra passed values are ignored.model_construct()
, having model_config.extra == 'forbid'
does not result in
an error if extra values are passed, but they will be ignored.Name | Description |
---|---|
**values | Type: Any |
Type | Description |
---|---|
Self | A new instance of the Model class with validated data. |
model_copy
Returns a copy of the model.__dict__
][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).Name | Description |
---|---|
update | Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. Type: Mapping[str, Any] | None Default: None |
deep | Set to True to make a deep copy of the model.Type: bool Default: False |
Type | Description |
---|---|
Self | New model instance. |
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.Name | Description |
---|---|
mode | 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. Type: “Literal[‘json’, ‘python’] | str” Default: ‘python’ |
include | A set of fields to include in the output. Type: IncEx | None Default: None |
exclude | A set of fields to exclude from the output. Type: IncEx | None Default: None |
context | Additional context to pass to the serializer. Type: Any | None Default: None |
by_alias | Whether to use the field’s alias in the dictionary key if defined. Type: bool | None Default: None |
exclude_unset | Whether to exclude fields that have not been explicitly set. Type: bool Default: False |
exclude_defaults | Whether to exclude fields that are set to their default value. Type: bool Default: False |
exclude_none | Whether to exclude fields that have a value of None .Type: bool Default: False |
round_trip | If True, dumped values should be valid as input for non-idempotent types such as Json[T]. Type: bool Default: False |
warnings | How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors, “error” raises a [ PydanticSerializationError ][pydantic_core.PydanticSerializationError].Type: “bool | Literal[‘none’, ‘warn’, ‘error’]“ Default: True |
fallback | A function to call when an unknown value is encountered. If not provided, a [ PydanticSerializationError ][pydantic_core.PydanticSerializationError] error is raised.Type: Callable[[Any], Any] | None Default: None |
serialize_as_any | Whether to serialize fields with duck-typing serialization behavior. Type: bool Default: False |
Type | Description |
---|---|
dict[str, typing.Any] | A dictionary representation of the model. |
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json
method.Name | Description |
---|---|
indent | Indentation to use in the JSON output. If None is passed, the output will be compact. Type: int | None Default: None |
include | Field(s) to include in the JSON output. Type: IncEx | None Default: None |
exclude | Field(s) to exclude from the JSON output. Type: IncEx | None Default: None |
context | Additional context to pass to the serializer. Type: Any | None Default: None |
by_alias | Whether to serialize using field aliases. Type: bool | None Default: None |
exclude_unset | Whether to exclude fields that have not been explicitly set. Type: bool Default: False |
exclude_defaults | Whether to exclude fields that are set to their default value. Type: bool Default: False |
exclude_none | Whether to exclude fields that have a value of None .Type: bool Default: False |
round_trip | If True, dumped values should be valid as input for non-idempotent types such as Json[T]. Type: bool Default: False |
warnings | How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors, “error” raises a [ PydanticSerializationError ][pydantic_core.PydanticSerializationError].Type: “bool | Literal[‘none’, ‘warn’, ‘error’]“ Default: True |
fallback | A function to call when an unknown value is encountered. If not provided, a [ PydanticSerializationError ][pydantic_core.PydanticSerializationError] error is raised.Type: Callable[[Any], Any] | None Default: None |
serialize_as_any | Whether to serialize fields with duck-typing serialization behavior. Type: bool Default: False |
Type | Description |
---|---|
str | A JSON string representation of the model. |
Name | Description |
---|---|
by_alias | Whether to use attribute aliases or not. Type: bool Default: True |
ref_template | The reference template. Type: str Default: ’#/$defs/{model}‘ |
schema_generator | To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modificationsType: type[GenerateJsonSchema] Default: pydantic.json_schema.GenerateJsonSchema |
mode | The mode in which to generate the schema. Type: JsonSchemaMode Default: ‘validation’ |
Type | Description |
---|---|
dict[str, typing.Any] | The JSON schema for the given model class. |
Name | Description |
---|---|
params | Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int] , the value (str, int) would be passed to params .Type: tuple[type[Any], …] |
Type | Description |
---|---|
str | String representing the new class where params are passed to cls as type variables. |
__init__
and model_construct
.Name | Description |
---|---|
context | Type: Any |
/ |
Name | Description |
---|---|
force | Whether to force the rebuilding of the model schema, defaults to False .Type: bool Default: False |
raise_errors | Whether to raise errors, defaults to True .Type: bool Default: True |
Name | Description |
---|---|
obj | The object to validate. Type: Any |
strict | Whether to enforce types strictly. Type: bool | None Default: None |
from_attributes | Whether to extract data from object attributes. Type: bool | None Default: None |
context | Additional context to pass to the validator. Type: Any | None Default: None |
by_alias | Whether to use the field’s alias when validating against the provided input data. Type: bool | None Default: None |
by_name | Whether to use the field’s name when validating against the provided input data. Type: bool | None Default: None |
Type | Description |
---|---|
Self | The validated model instance. |
Name | Description |
---|---|
json_data | The JSON data to validate. Type: str | bytes | bytearray |
strict | Whether to enforce types strictly. Type: bool | None Default: None |
context | Extra variables to pass to the validator. Type: Any | None Default: None |
by_alias | Whether to use the field’s alias when validating against the provided input data. Type: bool | None Default: None |
by_name | Whether to use the field’s name when validating against the provided input data. Type: bool | None Default: None |
Type | Description |
---|---|
Self | The validated Pydantic model. |
Name | Description |
---|---|
obj | The object containing string data to validate. Type: Any |
strict | Whether to enforce types strictly. Type: bool | None Default: None |
context | Extra variables to pass to the validator. Type: Any | None Default: None |
by_alias | Whether to use the field’s alias when validating against the provided input data. Type: bool | None Default: None |
by_name | Whether to use the field’s name when validating against the provided input data. Type: bool | None Default: None |
Type | Description |
---|---|
Self | The validated Pydantic model. |
Name | Description |
---|---|
path | Type: str | Path |
content_type | Type: str | None Default: None |
encoding | Type: str Default: ‘utf8’ |
proto | Type: DeprecatedParseProtocol | None Default: None |
allow_pickle | Type: bool Default: False |
Name | Description |
---|---|
obj | Type: Any |
Name | Description |
---|---|
b | Type: str | bytes |
content_type | Type: str | None Default: None |
encoding | Type: str Default: ‘utf8’ |
proto | Type: DeprecatedParseProtocol | None Default: None |
allow_pickle | Type: bool Default: False |
Name | Description |
---|---|
by_alias | Type: bool Default: True |
ref_template | Type: str Default: ’#/$defs/{model}‘ |
Name | Description |
---|---|
by_alias | Type: bool Default: True |
ref_template | Type: str Default: ’#/$defs/{model}‘ |
**dumps_kwargs | Type: Any |
Name | Description |
---|---|
**localns | Type: Any |
Name | Description |
---|---|
value | Type: Any |