diff --git a/.gitignore b/.gitignore index b6490a9..875117f 100644 --- a/.gitignore +++ b/.gitignore @@ -223,7 +223,7 @@ docs/* !docs/conf.py # Generated files -agentspeak.asl +*.asl diff --git a/src/control_backend/agents/bdi/agentspeak_generator.py b/src/control_backend/agents/bdi/agentspeak_generator.py index fba603a..7c9d8f0 100644 --- a/src/control_backend/agents/bdi/agentspeak_generator.py +++ b/src/control_backend/agents/bdi/agentspeak_generator.py @@ -18,6 +18,7 @@ from control_backend.agents.bdi.agentspeak_ast import ( StatementType, TriggerType, ) +from control_backend.core.config import settings from control_backend.schemas.program import ( BaseGoal, BasicNorm, @@ -524,6 +525,7 @@ class AgentSpeakGenerator: :return: The corresponding AgentSpeak statement. """ match step: + # Note that SpeechAction gets included in the ACHIEVE_GOAL, since it's a goal internally case Goal() | SpeechAction() | LLMAction() as a: return AstStatement(StatementType.ACHIEVE_GOAL, self._astify(a)) case GestureAction() as a: @@ -560,7 +562,12 @@ class AgentSpeakGenerator: subgoals.append(step) # Arbitrary wait for UI to display nicely - body.append(AstStatement(StatementType.DO_ACTION, AstLiteral("wait", [AstNumber(2000)]))) + body.append( + AstStatement( + StatementType.DO_ACTION, + AstLiteral("wait", [AstNumber(settings.behaviour_settings.trigger_time_to_wait)]), + ) + ) body.append( AstStatement( diff --git a/src/control_backend/agents/bdi/bdi_program_manager.py b/src/control_backend/agents/bdi/bdi_program_manager.py index 0cb224a..da57c25 100644 --- a/src/control_backend/agents/bdi/bdi_program_manager.py +++ b/src/control_backend/agents/bdi/bdi_program_manager.py @@ -75,7 +75,7 @@ class BDIProgramManager(BaseAgent): asl_str = asg.generate(program) - file_name = "src/control_backend/agents/bdi/agentspeak.asl" + file_name = settings.behaviour_settings.agentspeak_file with open(file_name, "w") as f: f.write(asl_str) diff --git a/src/control_backend/agents/communication/ri_communication_agent.py b/src/control_backend/agents/communication/ri_communication_agent.py index 252502d..5df5a13 100644 --- a/src/control_backend/agents/communication/ri_communication_agent.py +++ b/src/control_backend/agents/communication/ri_communication_agent.py @@ -145,7 +145,7 @@ class RICommunicationAgent(BaseAgent): # At this point, we have a valid response try: - self.logger.debug("Negotiation successful. Handling rn") + self.logger.debug("Negotiation successful.") await self._handle_negotiation_response(received_message) # Let UI know that we're connected topic = b"ping" diff --git a/src/control_backend/core/config.py b/src/control_backend/core/config.py index 329a246..6c2cf4e 100644 --- a/src/control_backend/core/config.py +++ b/src/control_backend/core/config.py @@ -77,6 +77,8 @@ class BehaviourSettings(BaseModel): :ivar transcription_words_per_token: Estimated words per token for transcription timing. :ivar transcription_token_buffer: Buffer for transcription tokens. :ivar conversation_history_length_limit: The maximum amount of messages to extract beliefs from. + :ivar trigger_time_to_wait: Amount of milliseconds to wait before informing the UI about trigger + completion. """ # ATTENTION: When adding/removing settings, make sure to update the .env.example file @@ -100,6 +102,10 @@ class BehaviourSettings(BaseModel): # Text belief extractor settings conversation_history_length_limit: int = 10 + # AgentSpeak related settings + trigger_time_to_wait: int = 2000 + agentspeak_file: str = "src/control_backend/agents/bdi/agentspeak.asl" + class LLMSettings(BaseModel): """ diff --git a/test/unit/agents/bdi/test_bdi_program_manager.py b/test/unit/agents/bdi/test_bdi_program_manager.py index 540a172..5771451 100644 --- a/test/unit/agents/bdi/test_bdi_program_manager.py +++ b/test/unit/agents/bdi/test_bdi_program_manager.py @@ -59,7 +59,7 @@ async def test_create_agentspeak_and_send_to_bdi(mock_settings): await manager._create_agentspeak_and_send_to_bdi(program) # Check file writing - mock_file.assert_called_with("src/control_backend/agents/bdi/agentspeak.asl", "w") + mock_file.assert_called_with(mock_settings.behaviour_settings.agentspeak_file, "w") handle = mock_file() handle.write.assert_called() @@ -67,7 +67,7 @@ async def test_create_agentspeak_and_send_to_bdi(mock_settings): msg: InternalMessage = manager.send.await_args[0][0] assert msg.thread == "new_program" assert msg.to == mock_settings.agent_settings.bdi_core_name - assert msg.body == "src/control_backend/agents/bdi/agentspeak.asl" + assert msg.body == mock_settings.behaviour_settings.agentspeak_file @pytest.mark.asyncio diff --git a/test/unit/conftest.py b/test/unit/conftest.py index d5f06e5..5e925d0 100644 --- a/test/unit/conftest.py +++ b/test/unit/conftest.py @@ -32,6 +32,7 @@ def mock_settings(): mock.agent_settings.vad_name = "vad_agent" mock.behaviour_settings.sleep_s = 0.01 # Speed up tests mock.behaviour_settings.comm_setup_max_retries = 1 + mock.behaviour_settings.agentspeak_file = "src/control_backend/agents/bdi/agentspeak.asl" yield mock