Skip to content

Commit

Permalink
Rename ComponentsContext to ComponentContextMapping.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 648671422
Change-Id: Ib23b6d78ef44112ad0da3128f201208fdb8b05df
  • Loading branch information
duenez authored and copybara-github committed Jul 2, 2024
1 parent bf553b7 commit f85d4e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 11 additions & 10 deletions concordia/components/agent/v2/simple_act_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class SimpleActComponent(component_v2.ActingComponent):
This component will receive the contexts from `pre_act` from all the
components, and assemble them in the order specified to `__init__`. If the
component order is not specified, then components will be assembled in the
iteration order of the `ComponentsContext` passed to `get_action_attempt`.
iteration order of the `ComponentContextMapping` passed to
`get_action_attempt`.
"""

def __init__(
Expand All @@ -43,13 +44,13 @@ def __init__(
model: The language model to use for generating the action attempt.
component_order: The order in which the component contexts will be
assembled when calling the act component. If None, the contexts will be
assembled in the iteration order of the `ComponentsContext` passed to
`get_action_attempt`. If the component order is specified, but does not
contain all the components passed to `get_action_attempt`, the missing
components will be appended at the end in the iteration order of the
`ComponentsContext` passed to `get_action_attempt`. The same component
cannot appear twice in the component order. All components in the
component order must be in the `ComponentsContext` passed to
assembled in the iteration order of the `ComponentContextMapping` passed
to `get_action_attempt`. If the component order is specified, but does
not contain all the components passed to `get_action_attempt`, the
missing components will be appended at the end in the iteration order of
the `ComponentContextMapping` passed to `get_action_attempt`. The same
component cannot appear twice in the component order. All components in
the component order must be in the `ComponentContextMapping` passed to
`get_action_attempt`.
Raises:
Expand All @@ -70,7 +71,7 @@ def __init__(

def _context_for_action(
self,
contexts: component_v2.ComponentsContext,
contexts: component_v2.ComponentContextMapping,
) -> str:
if self._component_order is None:
return "\n".join(
Expand All @@ -87,7 +88,7 @@ def _context_for_action(
@override
def get_action_attempt(
self,
contexts: component_v2.ComponentsContext,
contexts: component_v2.ComponentContextMapping,
action_spec: entity_lib.ActionSpec,
) -> str:
context = self._context_for_action(contexts)
Expand Down
4 changes: 2 additions & 2 deletions concordia/typing/component_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

ComponentName = str
ComponentContext = str
ComponentsContext = Mapping[ComponentName, ComponentContext]
ComponentContextMapping = Mapping[ComponentName, ComponentContext]


class BaseComponent:
Expand Down Expand Up @@ -144,7 +144,7 @@ class ActingComponent(BaseComponent, metaclass=abc.ABCMeta):
@abc.abstractmethod
def get_action_attempt(
self,
context: ComponentsContext,
context: ComponentContextMapping,
action_spec: entity_lib.ActionSpec,
) -> str:
"""Decides the action of an entity.
Expand Down

0 comments on commit f85d4e6

Please sign in to comment.