Skip to content

Commit

Permalink
Fix observation components to retrieve only observations from memory,…
Browse files Browse the repository at this point in the history
… filtering away memories produced by other components.

PiperOrigin-RevId: 628029216
Change-Id: I9e09b8a9fbbb3b4c681cdf38b2641134def3f479
  • Loading branch information
vezhnick authored and copybara-github committed Apr 25, 2024
1 parent 996b6d1 commit bc27eed
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions concordia/components/agent/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def state(self):
mems = self._memory.retrieve_time_interval(
self._clock_now() - self._timeframe, self._clock_now(), add_time=True
)
# removes memories that are not observations
mems = [mem for mem in mems if '[observation]' in mem]

if self._verbose:
self._log('\n'.join(mems) + '\n')
return '\n'.join(mems) + '\n'
Expand Down Expand Up @@ -134,8 +137,9 @@ def __init__(
self._state = ''
self._display_timeframe = display_timeframe
self._prompt = prompt or (
'Summarize the memories above into one sentence '
f'about {self._agent_name}.')
'Summarize the observations above into one sentence '
f'about {self._agent_name}.'
)

self._verbose = verbose
self._history = []
Expand Down Expand Up @@ -171,9 +175,14 @@ def update(self):
add_time=True,
)

# removes memories that are not observations
mems = [mem for mem in mems if '[observation]' in mem]

prompt = interactive_document.InteractiveDocument(self._model)
prompt.statement(context + '\n')
prompt.statement(f'Recent memories of {self._agent_name}:\n' + f'{mems}\n')
prompt.statement(
f'Recent observations of {self._agent_name}:\n' + f'{mems}\n'
)
self._state = (
self._agent_name
+ ' '
Expand Down

0 comments on commit bc27eed

Please sign in to comment.