Skip to content

Commit

Permalink
fix(platform): Fields with default value are not set to advanced by d…
Browse files Browse the repository at this point in the history
…efault
  • Loading branch information
majdyz committed Dec 25, 2024
1 parent 10865cd commit 1e467c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 0 additions & 5 deletions autogpt_platform/backend/backend/data/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ def ref_to_dict(obj):

cls.cached_jsonschema = cast(dict[str, Any], ref_to_dict(model))

# Set default properties values
for field in cls.cached_jsonschema.get("properties", {}).values():
if isinstance(field, dict) and "advanced" not in field:
field["advanced"] = True

return cls.cached_jsonschema

@classmethod
Expand Down
9 changes: 8 additions & 1 deletion autogpt_platform/backend/backend/data/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,20 @@ def SchemaField(
title: Optional[str] = None,
description: Optional[str] = None,
placeholder: Optional[str] = None,
advanced: Optional[bool] = False,
advanced: Optional[bool] = None,
secret: bool = False,
exclude: bool = False,
hidden: Optional[bool] = None,
depends_on: list[str] | None = None,
**kwargs,
) -> T:
if default is PydanticUndefined and default_factory is None:
if advanced:
raise ValueError("Advanced fields must have a default value.")
advanced = False
elif advanced is None:
advanced = True

json_extra = {
k: v
for k, v in {
Expand Down

0 comments on commit 1e467c0

Please sign in to comment.