graphragzen.entity_extraction.typing.EntityExtractionPrompts
- class graphragzen.entity_extraction.typing.EntityExtractionPrompts[source]
Base prompts for entity extraction
- Parameters:
entity_extraction_prompt (str, optional) – Main extraction prompt. Defaults to graphragzen.prompts.default_prompts.entity_extraction_prompts.ENTITY_EXTRACTION_PROMPT
continue_prompt (str, optional) – Prompt that asks the LLM to continue extracting entities. Defaults to graphragzen.prompts.default_prompts.entity_extraction_prompts.CONTINUE_PROMPT
loop_prompt (str, optional) – Prompt that asks the LLM if there are more entities to extract. Defaults to graphragzen.prompts.default_prompts.entity_extraction_prompts.LOOP_PROMPT
Attributes
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Get extra fields set during validation.
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
Returns the set of fields that have been explicitly set on this model instance.
Methods
construct([_fields_set])copy(*[, include, exclude, update, deep])Returns a copy of the model.
dict(*[, include, exclude, by_alias, ...])from_orm(obj)get(k[,d])items()json(*[, include, exclude, by_alias, ...])keys()model_construct([_fields_set])Creates a new instance of the Model class with validated data.
model_copy(*[, update, deep])Usage docs: https://docs.pydantic.dev/2.7/concepts/serialization/#model_copy
model_dump(*[, mode, include, exclude, ...])Usage docs: https://docs.pydantic.dev/2.7/concepts/serialization/#modelmodel_dump
model_dump_json(*[, indent, include, ...])Usage docs: https://docs.pydantic.dev/2.7/concepts/serialization/#modelmodel_dump_json
model_json_schema([by_alias, ref_template, ...])Generates a JSON schema for a model class.
model_parametrized_name(params)Compute the class name for parametrizations of generic classes.
model_post_init(_BaseModel__context)Override this method to perform additional initialization after __init__ and model_construct.
model_rebuild(*[, force, raise_errors, ...])Try to rebuild the pydantic-core schema for the model.
model_validate(obj, *[, strict, ...])Validate a pydantic model instance.
model_validate_json(json_data, *[, strict, ...])Usage docs: https://docs.pydantic.dev/2.7/concepts/json/#json-parsing
model_validate_strings(obj, *[, strict, context])Validate the given object contains string data against the Pydantic model.
parse_file(path, *[, content_type, ...])parse_obj(obj)parse_raw(b, *[, content_type, encoding, ...])schema([by_alias, ref_template])schema_json(*[, by_alias, ref_template])update_forward_refs(**localns)validate(value)values()- __init__(**data)
Create a new model by parsing and validating input data from keyword arguments.
Raises [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:
self (Self)
data (Any)
- Return type:
None
- classmethod construct(_fields_set=None, **values)
- Parameters:
_fields_set (set[str] | None)
values (Any)
- Return type:
Model
- continue_prompt: str
- copy(*, include=None, exclude=None, update=None, deep=False)
Returns a copy of the model.
- !!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
`py data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `- Parameters:
include (AbstractSetIntStr | MappingIntStrAny | None) – Optional set or mapping specifying which fields to include in the copied model.
exclude (AbstractSetIntStr | MappingIntStrAny | None) – Optional set or mapping specifying which fields to exclude in the copied model.
update (Dict[str, Any] | None) – Optional dictionary of field-value pairs to override field values in the copied model.
deep (bool) – If True, the values of fields that are Pydantic models will be deep-copied.
self (Model)
- Returns:
A copy of the model with included, excluded and updated fields as specified.
- Return type:
Model
- dict(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)
- Parameters:
include (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None)
exclude (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None)
by_alias (bool)
exclude_unset (bool)
exclude_defaults (bool)
exclude_none (bool)
- Return type:
Dict[str, Any]
- entity_extraction_prompt: str
- classmethod from_orm(obj)
- Parameters:
obj (Any)
- Return type:
Model
- get(k[, d]) D[k] if k in D, else d. d defaults to None.
- items() a set-like object providing a view on D's items
- json(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=PydanticUndefined, models_as_dict=PydanticUndefined, **dumps_kwargs)
- Parameters:
include (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None)
exclude (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None)
by_alias (bool)
exclude_unset (bool)
exclude_defaults (bool)
exclude_none (bool)
encoder (Callable[[Any], Any] | None)
models_as_dict (bool)
dumps_kwargs (Any)
- Return type:
str
- keys() a set-like object providing a view on D's keys
- loop_prompt: str
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set=None, **values)
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if 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. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Parameters:
_fields_set (set[str] | None) – The set of field names accepted for the Model instance.
values (Any) – Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- Return type:
Model
- model_copy(*, update=None, deep=False)
Usage docs: https://docs.pydantic.dev/2.7/concepts/serialization/#model_copy
Returns a copy of the model.
- Parameters:
update (dict[str, Any] | None) – Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.
deep (bool) – Set to True to make a deep copy of the model.
self (Model)
- Returns:
New model instance.
- Return type:
Model
- model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, round_trip=False, warnings=True, serialize_as_any=False)
Usage docs: https://docs.pydantic.dev/2.7/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Parameters:
mode (Literal['json', 'python'] | str) – 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.
include (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None) – A set of fields to include in the output.
exclude (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None) – A set of fields to exclude from the output.
context (dict[str, Any] | None) – Additional context to pass to the serializer.
by_alias (bool) – Whether to use the field’s alias in the dictionary key if defined.
exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.
exclude_defaults (bool) – Whether to exclude fields that are set to their default value.
exclude_none (bool) – Whether to exclude fields that have a value of None.
round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings (bool | Literal['none', 'warn', 'error']) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- Return type:
dict[str, Any]
- model_dump_json(*, indent=None, include=None, exclude=None, context=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, round_trip=False, warnings=True, serialize_as_any=False)
Usage docs: https://docs.pydantic.dev/2.7/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Parameters:
indent (int | None) – Indentation to use in the JSON output. If None is passed, the output will be compact.
include (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None) – Field(s) to include in the JSON output.
exclude (Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None) – Field(s) to exclude from the JSON output.
context (dict[str, Any] | None) – Additional context to pass to the serializer.
by_alias (bool) – Whether to serialize using field aliases.
exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.
exclude_defaults (bool) – Whether to exclude fields that are set to their default value.
exclude_none (bool) – Whether to exclude fields that have a value of None.
round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings (bool | Literal['none', 'warn', 'error']) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- Return type:
str
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[dict[str, FieldInfo]] = {'continue_prompt': FieldInfo(annotation=str, required=False, default='MANY nodes and edges were missed in the last extraction. Add only THE MISSING entities\n\n \n -Steps-\n 1. Identify all MISSING nodes. For each node, extract the following information:\n - name: Name of the node, capitalized\n - category: One of the following categories: [{entity_categories}]\n - description: Comprehensive description of the node\'s attributes and activities\n Format each node as a JSON with the following format:\n {{"type": "node", "name": <name>, "category": <category>, "description": <description>}}\n\n 2. From the nodes identified in step 1, identify all MISSING pairs of (source_node, target_node) that are *clearly related* to each other.\n For each edge, extract the following information:\n - source: name of the source node, as identified in step 1\n - target: name of the target node, as identified in step 1\n - description: explanation as to why you think the source node and the target node are related to each other\n - weight: a numeric score indicating strength of the edge between the source node and target node\n Format each edge as a JSON with the following format:\n {{"type": "edge", "source": <source>, "target": <target>, "description": <description>, "weight": <weight>}}\n'), 'entity_extraction_prompt': FieldInfo(annotation=str, required=False, default='\nYou are an intelligent assistant that helps a human to analyze the information in a text document and extract a knowledg graph from it. A knowledge graph consists of nodes and their edges (relationships between the nodes in the graph).\n\n-Goal-\nGiven a text document that is potentially relevant to this activity and a list of categories, identify all nodes of those categories from the text and all edges among the identified nodes.\n\n-Steps-\n1. Identify all nodes. For each identified node, extract the following information:\n- name: Name of the node, capitalized\n- category: One of the following categories: [{entity_categories}]\n- description: Short, comprehensive description of the node\'s attributes and activities\nFormat each node as a JSON with the following format:\n{{"type": "node", "name": <name>, "category": <category>, "description": <description>}}\n\n2. From the nodes identified in step 1, identify all pairs of (source_node, target_node) that are *clearly related* to each other.\nFor each edge, extract the following information:\n- source: name of the source node, as identified in step 1\n- target: name of the target node, as identified in step 1\n- description: Short explanation as to why you think the source node and the target node are related to each other\n- weight: a numeric score indicating strength of the edge between the source node and target node\nFormat each edge as a JSON with the following format:\n{{"type": "edge", "source": <source>, "target": <target>, "description": <description>, "weight": <weight>}}\n\n3. Return output in English as a single list of all JSON entities and relationships identified in steps 1 and 2.\n\n######################\n-Examples-\n######################\nExample 1:\n\nEntity_categories: [person, technology, mission, organization, location]\nText:\nwhile Alex clenched his jaw, the buzz of frustration dull against the backdrop of Taylor\'s authoritarian certainty. It was this competitive undercurrent that kept him alert, the sense that his and Jordan\'s shared commitment to discovery was an unspoken rebellion against Cruz\'s narrowing vision of control and order.\n\nThen Taylor did something unexpected. They paused beside Jordan and, for a moment, observed the device with something akin to reverence. “If this tech can be understood..." Taylor said, their voice quieter, "It could change the game for us. For all of us.”\n\nThe underlying dismissal earlier seemed to falter, replaced by a glimpse of reluctant respect for the gravity of what lay in their hands. Jordan looked up, and for a fleeting heartbeat, their eyes locked with Taylor\'s, a wordless clash of wills softening into an uneasy truce.\n\nIt was a small transformation, barely perceptible, but one that Alex noted with an inward nod. They had all been brought here by different paths\n################\nOutput:\n[\n {{\n "type": "node",\n "name": "ALEX",\n "category": "PERSON",\n "description": "Alex is a character who experiences frustration and is observant of the dynamics among other characters."\n }},\n {{\n "type": "node",\n "name": "TAYLOR",\n "category": "PERSON",\n "description": "Taylor is portrayed with authoritarian certainty and shows a moment of reverence towards a device, indicating a change in perspective."\n }},\n {{\n "type": "node",\n "name": "JORDAN",\n "category": "PERSON",\n "description": "Jordan shares a commitment to discovery and has a significant interaction with Taylor regarding a device."\n }},\n {{\n "type": "node",\n "name": "CRUZ",\n "category": "PERSON",\n "description": "Cruz is associated with a vision of control and order, influencing the dynamics among other characters."\n }},\n {{\n "type": "node",\n "name": "THE DEVICE",\n "category": "TECHNOLOGY",\n "description": "The Device is central to the story, with potential game-changing implications, and is revered by Taylor."\n }},\n {{\n "type": "edge",\n "source": "ALEX",\n "target": "TAYLOR",\n "descripton": "Alex is affected by Taylor\'s authoritarian certainty and observes changes in Taylor\'s attitude towards the device.",\n "weight": 1.0\n }},\n {{\n "type": "edge",\n "source": "ALEX",\n "target": "JORDAN",\n "descripton": "Alex and Jordan share a commitment to discovery, which contrasts with Cruz\'s vision.",\n "weight": 1.0\n }},\n {{\n "type": "edge",\n "source": "TAYLOR",\n "target": "JORDAN",\n "descripton": "Taylor and Jordan interact directly regarding the device, leading to a moment of mutual respect and an uneasy truce.",\n "weight": 1.0\n }},\n {{\n "type": "edge",\n "source": "JORDAN",\n "target": "CRUZ",\n "descripton": "Jordan\'s commitment to discovery is in rebellion against Cruz\'s vision of control and order.",\n "weight": 1.0\n }},\n {{\n "type": "edge",\n "source": "TAYLOR",\n "target": "THE DEVICE",\n "descripton": "Taylor shows reverence towards the device, indicating its importance and potential impact.",\n "weight": 1.0\n }}\n]\n#############################\nExample 2:\n\nEntity_categories: [person, technology, mission, organization, location]\nText:\nThey were no longer mere operatives; they had become guardians of a threshold, keepers of a message from a realm beyond stars and stripes. This elevation in their mission could not be shackled by regulations and established protocols—it demanded a new perspective, a new resolve.\n\nTension threaded through the dialogue of beeps and static as communications with Washington buzzed in the background. The team stood, a portentous air enveloping them. It was clear that the decisions they made in the ensuing hours could redefine humanity\'s place in the cosmos or condemn them to ignorance and potential peril.\n\nTheir connection to the stars solidified, the group moved to address the crystallizing warning, shifting from passive recipients to active participants. Mercer\'s latter instincts gained precedence— the team\'s mandate had evolved, no longer solely to observe and report but to interact and prepare. A metamorphosis had begun, and Operation: Dulce hummed with the newfound frequency of their daring, a tone set not by the earthly\n#############\nOutput:\n[\n {{\n "type": "node",\n "name": "WASHINGTON",\n "category": "LOCATION",\n "description": "Washington is a location where communications are being received, indicating its importance in the decision-making process."\n }},\n {{\n "type": "node",\n "name": "OPERATION: DULCE",\n "category": "MISSION",\n "description": "Operation: Dulce is described as a mission that has evolved to interact and prepare, indicating a significant shift in objectives and activities."\n }},\n {{\n "type": "node",\n "name": "THE TEAM",\n "category": "ORGANIZATION",\n "description": "The team is portrayed as a group of individuals who have transitioned from passive observers to active participants in a mission, showing a dynamic change in their role."\n }},\n {{\n "type": "edge",\n "source": "THE TEAM",\n "target": "WASHINGTON",\n "descripton": "The team receives communications from Washington, which influences their decision-making process.",\n "weight": 1.0\n }},\n {{\n "type": "edge",\n "source": "THE TEAM",\n "target": "OPERATION: DULCE",\n "descripton": "The team is directly involved in Operation: Dulce, executing its evolved objectives and activities.",\n "weight": 1.0\n }}\n]\n#############################\nExample 3:\n\nEntity_categories: [person, role, technology, organization, event, location, concept]\nText:\ntheir voice slicing through the buzz of activity. "Control may be an illusion when facing an intelligence that literally writes its own rules," they stated stoically, casting a watchful eye over the flurry of data.\n\n"It\'s like it\'s learning to communicate," offered Sam Rivera from a nearby interface, their youthful energy boding a mix of awe and anxiety. "This gives talking to strangers\' a whole new meaning."\n\nAlex surveyed his team—each face a study in concentration, determination, and not a small measure of trepidation. "This might well be our first contact," he acknowledged, "And we need to be ready for whatever answers back."\n\nTogether, they stood on the edge of the unknown, forging humanity\'s response to a message from the heavens. The ensuing silence was palpable—a collective introspection about their role in this grand cosmic play, one that could rewrite human history.\n\nThe encrypted dialogue continued to unfold, its intricate patterns showing an almost uncanny anticipation\n#############\nOutput:\n[\n {{\n "type": "node",\n "name": "SAM RIVERA",\n "category": "PERSON",\n "description": "Sam Rivera is a member of a team working on communicating with an unknown intelligence, showing a mix of awe and anxiety."\n }},\n {{\n "type": "node",\n "name": "ALEX",\n "category": "PERSON",\n "description": "Alex is the leader of a team attempting first contact with an unknown intelligence, acknowledging the significance of their task."\n }},\n {{\n "type": "node",\n "name": "CONTROL",\n "category": "CONCEPT",\n "description": "Control refers to the ability to manage or govern, which is challenged by an intelligence that writes its own rules."\n }},\n {{\n "type": "node",\n "name": "INTELLIGENCE",\n "category": "CONCEPT",\n "description": "Intelligence here refers to an unknown entity capable of writing its own rules and learning to communicate."\n }},\n {{\n "type": "node",\n "name": "FIRST CONTACT",\n "category": "EVENT",\n "description": "First Contact is the potential initial communication between humanity and an unknown intelligence."\n }},\n {{\n "type": "node",\n "name": "HUMANITY\'S RESPONSE",\n "category": "EVENT",\n "description": "Humanity\'s Response is the collective action taken by Alex\'s team in response to a message from an unknown intelligence."\n }},\n {{\n "type": "edge",\n "source": "SAM RIVERA",\n "target": "INTELLIGENCE",\n "descripton": "Sam Rivera is directly involved in the process of learning to communicate with the unknown intelligence.",\n "weight": 1.0\n }},\n {{\n "type": "edge",\n "source": "ALEX",\n "target": "FIRST CONTACT",\n "descripton": "Alex leads the team that might be making the First Contact with the unknown intelligence.",\n "weight": 1.0\n }},\n {{\n "type": "edge",\n "source": "ALEX",\n "target": "HUMANITY\'S RESPONSE",\n "descripton": "Alex and his team are the key figures in Humanity\'s Response to the unknown intelligence.",\n "weight": 1.0\n }},\n {{\n "type": "edge",\n "source": "CONTROL",\n "target": "INTELLIGENCE",\n "descripton": "The concept of Control is challenged by the Intelligence that writes its own rules.",\n "weight": 1.0\n }}\n]\n#############################\n-Real Data-\n######################\nEntity_categories: {entity_categories}\nText: {input_text}\n######################\nOutput:'), 'loop_prompt': FieldInfo(annotation=str, required=False, default='It appears some nodes and edges may have still been missed.\nAnswer YES | NO if there are still nodes or edges that need to be added.\nDo not explain yourself, do not extract more entities, answer only either YES | NO:\n')}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation')
Generates a JSON schema for a model class.
- Parameters:
by_alias (bool) – Whether to use attribute aliases or not.
ref_template (str) – The reference template.
schema_generator (type[GenerateJsonSchema]) – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications
mode (Literal['validation', 'serialization']) – The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- Return type:
dict[str, Any]
- classmethod model_parametrized_name(params)
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Parameters:
params (tuple[type[Any], ...]) – 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.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError – Raised when trying to generate concrete names for non-generic models.
- Return type:
str
- model_post_init(_BaseModel__context)
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- Parameters:
_BaseModel__context (Any)
- Return type:
None
- classmethod model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Parameters:
force (bool) – Whether to force the rebuilding of the model schema, defaults to False.
raise_errors (bool) – Whether to raise errors, defaults to True.
_parent_namespace_depth (int) – The depth level of the parent namespace, defaults to 2.
_types_namespace (dict[str, Any] | None) – The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- Return type:
bool | None
- classmethod model_validate(obj, *, strict=None, from_attributes=None, context=None)
Validate a pydantic model instance.
- Parameters:
obj (Any) – The object to validate.
strict (bool | None) – Whether to enforce types strictly.
from_attributes (bool | None) – Whether to extract data from object attributes.
context (dict[str, Any] | None) – Additional context to pass to the validator.
- Raises:
ValidationError – If the object could not be validated.
- Returns:
The validated model instance.
- Return type:
Model
- classmethod model_validate_json(json_data, *, strict=None, context=None)
Usage docs: https://docs.pydantic.dev/2.7/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Parameters:
json_data (str | bytes | bytearray) – The JSON data to validate.
strict (bool | None) – Whether to enforce types strictly.
context (dict[str, Any] | None) – Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValueError – If json_data is not a JSON string.
- Return type:
Model
- classmethod model_validate_strings(obj, *, strict=None, context=None)
Validate the given object contains string data against the Pydantic model.
- Parameters:
obj (Any) – The object contains string data to validate.
strict (bool | None) – Whether to enforce types strictly.
context (dict[str, Any] | None) – Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Return type:
Model
- classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)
- Parameters:
path (str | Path)
content_type (str | None)
encoding (str)
proto (DeprecatedParseProtocol | None)
allow_pickle (bool)
- Return type:
Model
- classmethod parse_obj(obj)
- Parameters:
obj (Any)
- Return type:
Model
- classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)
- Parameters:
b (str | bytes)
content_type (str | None)
encoding (str)
proto (DeprecatedParseProtocol | None)
allow_pickle (bool)
- Return type:
Model
- classmethod schema(by_alias=True, ref_template='#/$defs/{model}')
- Parameters:
by_alias (bool)
ref_template (str)
- Return type:
Dict[str, Any]
- classmethod schema_json(*, by_alias=True, ref_template='#/$defs/{model}', **dumps_kwargs)
- Parameters:
by_alias (bool)
ref_template (str)
dumps_kwargs (Any)
- Return type:
str
- classmethod update_forward_refs(**localns)
- Parameters:
localns (Any)
- Return type:
None
- classmethod validate(value)
- Parameters:
value (Any)
- Return type:
Model
- values() an object providing a view on D's values