allow increment to go backward with n-1 and also support any int c for the

increment or decrement.

	modified:   ../app.py
	modified:   guarded_ai.py
This commit is contained in:
Russell Ballestrini 2024-08-10 15:00:28 -04:00
parent e3d3bf0303
commit 058b0161df
2 changed files with 14 additions and 4 deletions

9
app.py
View file

@ -2164,8 +2164,13 @@ def handle_activity_response(room_name, user_response, username):
for key, value in transition["metadata_add"].items():
if value == "the-users-response":
value = user_response
elif value == "n+1":
value = activity_state.dict_metadata.get(key, 0) + 1
elif isinstance(value, str) and (value.startswith("n+") or value.startswith("n-")):
# Extract the numeric part c and apply the operation +/-
c = int(value[1:])
if value.startswith("n+"):
value = metadata.get(key, 0) + c
elif value.startswith("n-"):
value = metadata.get(key, 0) - c
new_metadata[key] = value
activity_state.add_metadata(key, value)