chore: small changes
This commit is contained in:
@@ -7,7 +7,7 @@ from zmq.asyncio import Context
|
|||||||
|
|
||||||
from control_backend.agents import BaseAgent
|
from control_backend.agents import BaseAgent
|
||||||
from control_backend.agents.actuation.robot_gesture_agent import RobotGestureAgent
|
from control_backend.agents.actuation.robot_gesture_agent import RobotGestureAgent
|
||||||
from control_backend.agents.perception.visual_emotion_detection_agent.visual_emotion_recognition_agent import (
|
from control_backend.agents.perception.visual_emotion_recognition_agent.visual_emotion_recognition_agent import (
|
||||||
VisualEmotionRecognitionAgent,
|
VisualEmotionRecognitionAgent,
|
||||||
)
|
)
|
||||||
from control_backend.core.config import settings
|
from control_backend.core.config import settings
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import zmq
|
|||||||
import zmq.asyncio as azmq
|
import zmq.asyncio as azmq
|
||||||
|
|
||||||
from control_backend.agents import BaseAgent
|
from control_backend.agents import BaseAgent
|
||||||
from control_backend.agents.perception.visual_emotion_detection_agent.visual_emotion_recognizer import (
|
from control_backend.agents.perception.visual_emotion_recognition_agent.visual_emotion_recognizer import (
|
||||||
DeepFaceEmotionRecognizer,
|
DeepFaceEmotionRecognizer,
|
||||||
)
|
)
|
||||||
from control_backend.core.agent_system import InternalMessage
|
from control_backend.core.agent_system import InternalMessage
|
||||||
@@ -105,11 +105,10 @@ class VisualEmotionRecognitionAgent(BaseAgent):
|
|||||||
Compare emotions from previous window and current emotions,
|
Compare emotions from previous window and current emotions,
|
||||||
send updates to BDI Core Agent.
|
send updates to BDI Core Agent.
|
||||||
"""
|
"""
|
||||||
# Remove emotions that are no longer present
|
|
||||||
emotions_to_remove = prev_emotions - emotions
|
emotions_to_remove = prev_emotions - emotions
|
||||||
new_emotions = emotions - prev_emotions
|
emotions_to_add = emotions - prev_emotions
|
||||||
|
|
||||||
if not new_emotions and not emotions_to_remove:
|
if not emotions_to_add and not emotions_to_remove:
|
||||||
return
|
return
|
||||||
|
|
||||||
emotion_beliefs = []
|
emotion_beliefs = []
|
||||||
@@ -122,18 +121,20 @@ class VisualEmotionRecognitionAgent(BaseAgent):
|
|||||||
self.logger.warning("Invalid belief for emotion removal: %s", emotion)
|
self.logger.warning("Invalid belief for emotion removal: %s", emotion)
|
||||||
|
|
||||||
# Add new emotions that have appeared
|
# Add new emotions that have appeared
|
||||||
for emotion in new_emotions:
|
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.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]
|
||||||
|
payload = {"beliefs": beliefs_list}
|
||||||
|
|
||||||
message = InternalMessage(
|
message = InternalMessage(
|
||||||
to=settings.agent_settings.bdi_core_name,
|
to=settings.agent_settings.bdi_core_name,
|
||||||
sender=self.name,
|
sender=self.name,
|
||||||
body=json.dumps(emotion_beliefs),
|
body=json.dumps(payload),
|
||||||
thread="beliefs",
|
thread="beliefs",
|
||||||
)
|
)
|
||||||
self.logger.debug("Sending emotion beliefs update: %s", emotion_beliefs)
|
|
||||||
await self.send(message)
|
await self.send(message)
|
||||||
@@ -40,9 +40,6 @@ from control_backend.agents.communication import RICommunicationAgent
|
|||||||
from control_backend.agents.llm import LLMAgent
|
from control_backend.agents.llm import LLMAgent
|
||||||
|
|
||||||
# User Interrupt Agent
|
# User Interrupt Agent
|
||||||
from control_backend.agents.perception.visual_emotion_detection_agent.visual_emotion_recognition_agent import (
|
|
||||||
VisualEmotionRecognitionAgent,
|
|
||||||
)
|
|
||||||
from control_backend.agents.user_interrupt.user_interrupt_agent import UserInterruptAgent
|
from control_backend.agents.user_interrupt.user_interrupt_agent import UserInterruptAgent
|
||||||
|
|
||||||
# Other backend imports
|
# Other backend imports
|
||||||
|
|||||||
Reference in New Issue
Block a user