Skip to content

Commit

Permalink
Only add to memory if the state has changed
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 602669867
Change-Id: I3f90dbce4f91933fa27037d98701e53753814664
  • Loading branch information
vezhnick authored and copybara-github committed Jan 30, 2024
1 parent 06b5388 commit b50d4eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion concordia/components/agent/person_by_situation.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def update(self) -> None:
if self._clock_now is not None:
question = f'Current time: {self._clock_now()}.\n{question}'

old_state = self._state
self._state = prompt.open_question(
question,
answer_prefix=f'{self._agent_name} would ',
Expand All @@ -106,7 +107,8 @@ def update(self) -> None:

self._state = f'{self._agent_name} would {self._state}'

self._memory.add(f'[intent reflection] {self._state}')
if old_state != self._state:
self._memory.add(f'[intent reflection] {self._state}')

self._last_chain = prompt
if self._verbose:
Expand Down
5 changes: 3 additions & 2 deletions concordia/components/agent/self_perception.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def update(self) -> None:
question = (
f'Given the memories above, what kind of person is {self._agent_name}?'
)

old_state = self._state
self._state = prompt.open_question(
question,
answer_prefix=f'{self._agent_name} is ',
Expand All @@ -94,7 +94,8 @@ def update(self) -> None:

self._state = f'{self._agent_name} is {self._state}'

self._memory.add(f'[self reflection] {self._state}')
if old_state != self._state:
self._memory.add(f'[self reflection] {self._state}')

self._last_chain = prompt
if self._verbose:
Expand Down

0 comments on commit b50d4eb

Please sign in to comment.