We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4afc9b2 commit 77ed1f5Copy full SHA for 77ed1f5
src/google/adk/sessions/state.py
@@ -48,6 +48,14 @@ def __contains__(self, key: str) -> bool:
48
"""Whether the state dict contains the given key."""
49
return key in self._value or key in self._delta
50
51
+ def setdefault(self, key: str, default: Any = None) -> Any:
52
+ """Gets the value of a key, or sets it to a default if the key doesn't exist."""
53
+ if key in self:
54
+ return self[key]
55
+ else:
56
+ self[key] = default
57
+ return default
58
+
59
def has_delta(self) -> bool:
60
"""Whether the state has pending delta."""
61
return bool(self._delta)
0 commit comments