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
Using pydanitc classes for the json schema as we are doing it is possible to write custom validators for the classes to ensure that the data is valid when used in the code later.
Examples where this can be useful is to ensure that all the ranges in agent_output_indexes are valid ranges (either an integer or integers with ":" in between).
This can be added by using the @validator decorator. This can be done as shown below:
class InternalState(BaseModelConfig):
...
@validator("name", "start_value", "initialization_variable")
def check_only_one_initialization(self, v: Any, values: Dict[str, Any]):
if "initialization_variable" in values and ("start_value" in values or "name" in values):
raise ValueError(
"Only one state initialization method is allowed to be used at a time: initialization_variable cannot be set if either start_value or name is set."
)
if "start_value" not in values and "name" in values:
raise ValueError(
"name is set without start_value being set. Both fields needs to be set for the state initialization to be valid"
)
if "start_value" in values and "name" not in values:
raise ValueError(
"start_value is set without name being set. Both fields needs to be set for the state initialization to be valid"
)
return v
The text was updated successfully, but these errors were encountered:
Using pydanitc classes for the json schema as we are doing it is possible to write custom validators for the classes to ensure that the data is valid when used in the code later.
Examples where this can be useful is to ensure that all the ranges in
agent_output_indexes
are valid ranges (either an integer or integers with ":" in between).This can be added by using the @validator decorator. This can be done as shown below:
The text was updated successfully, but these errors were encountered: