fix: made mapping for conditional norms only
ref: N25B-400
This commit is contained in:
@@ -415,6 +415,11 @@ class AgentSpeakGenerator:
|
||||
def slugify(element: ProgramElement) -> str:
|
||||
raise NotImplementedError(f"Cannot convert element {element} to a slug.")
|
||||
|
||||
@slugify.register
|
||||
@staticmethod
|
||||
def _(n: Norm) -> str:
|
||||
return f"norm_{AgentSpeakGenerator._slugify_str(n.norm)}"
|
||||
|
||||
@slugify.register
|
||||
@staticmethod
|
||||
def _(sb: SemanticBelief) -> str:
|
||||
|
||||
@@ -8,7 +8,7 @@ from control_backend.agents import BaseAgent
|
||||
from control_backend.agents.bdi.agentspeak_generator import AgentSpeakGenerator
|
||||
from control_backend.core.agent_system import InternalMessage
|
||||
from control_backend.core.config import settings
|
||||
from control_backend.schemas.program import Program
|
||||
from control_backend.schemas.program import BasicNorm, Program
|
||||
from control_backend.schemas.ri_message import GestureCommand, RIEndpoint, SpeechCommand
|
||||
|
||||
|
||||
@@ -211,15 +211,17 @@ class UserInterruptAgent(BaseAgent):
|
||||
self._goal_map[str(goal.id)] = AgentSpeakGenerator.slugify(goal)
|
||||
|
||||
for norm in phase.norms:
|
||||
if norm.condition:
|
||||
if not isinstance(norm, BasicNorm):
|
||||
asl_slug = AgentSpeakGenerator.slugify(norm)
|
||||
belief_id = str(norm.condition)
|
||||
|
||||
belief_id = str(norm.condition.id)
|
||||
|
||||
self._cond_norm_map[belief_id] = asl_slug
|
||||
self._cond_norm_reverse_map[asl_slug] = belief_id
|
||||
|
||||
self.logger.info(
|
||||
f"Mapped {len(self._trigger_map)} triggers and {len(self._goal_map)} goals."
|
||||
f"Mapped {len(self._trigger_map)} triggers and {len(self._goal_map)} goals "
|
||||
f"and {len(self._cond_norm_map)} conditional norms for UserInterruptAgent."
|
||||
)
|
||||
except Exception as e:
|
||||
self.logger.error(f"Mapping failed: {e}")
|
||||
|
||||
Reference in New Issue
Block a user