feat: face recognition agent #53
@@ -111,25 +111,27 @@ class VisualEmotionRecognitionAgent(BaseAgent):
|
|||||||
if not emotions_to_add and not emotions_to_remove:
|
if not emotions_to_add and not emotions_to_remove:
|
||||||
return
|
return
|
||||||
|
|
||||||
emotion_beliefs = []
|
emotion_beliefs_remove = []
|
||||||
# Remove emotions that have disappeared
|
# Remove emotions that have disappeared
|
||||||
for emotion in emotions_to_remove:
|
for emotion in emotions_to_remove:
|
||||||
self.logger.info(f"Emotion '{emotion}' has disappeared.")
|
self.logger.info(f"Emotion '{emotion}' has disappeared.")
|
||||||
try:
|
try:
|
||||||
emotion_beliefs.append(Belief(name="emotion", arguments=[emotion], remove=True))
|
emotion_beliefs_remove.append(Belief(name="emotion", arguments=[emotion], remove=True))
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
self.logger.warning("Invalid belief for emotion removal: %s", emotion)
|
self.logger.warning("Invalid belief for emotion removal: %s", emotion)
|
||||||
|
|
||||||
|
emotion_beliefs_add = []
|
||||||
# Add new emotions that have appeared
|
# Add new emotions that have appeared
|
||||||
for emotion in emotions_to_add:
|
for emotion in emotions_to_add:
|
||||||
self.logger.info(f"New emotion detected: '{emotion}'")
|
self.logger.info(f"New emotion detected: '{emotion}'")
|
||||||
try:
|
try:
|
||||||
emotion_beliefs.append(Belief(name="emotion", arguments=[emotion]))
|
emotion_beliefs_add.append(Belief(name="emotion", arguments=[emotion]))
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
self.logger.warning("Invalid belief for new emotion: %s", emotion)
|
self.logger.warning("Invalid belief for new emotion: %s", emotion)
|
||||||
|
|
||||||
beliefs_list = [b.model_dump() for b in emotion_beliefs]
|
beliefs_list_add = [b.model_dump() for b in emotion_beliefs_add]
|
||||||
payload = {"beliefs": beliefs_list}
|
beliefs_list_remove = [b.model_dump() for b in emotion_beliefs_remove]
|
||||||
|
payload = {"create": beliefs_list_add, "delete": beliefs_list_remove, "replace": []}
|
||||||
|
|
||||||
message = InternalMessage(
|
message = InternalMessage(
|
||||||
to=settings.agent_settings.bdi_core_name,
|
to=settings.agent_settings.bdi_core_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user