feat: apply new agent naming standards
Expanding abbreviations to remove ambiguity, simplifying agent names to reduce repetition. ref: N25B-257
This commit is contained in:
@@ -1 +0,0 @@
|
||||
from .act_speech_agent import ActSpeechAgent as ActSpeechAgent
|
||||
1
src/control_backend/agents/actuation/__init__.py
Normal file
1
src/control_backend/agents/actuation/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .robot_speech_agent import RobotSpeechAgent as RobotSpeechAgent
|
||||
@@ -10,7 +10,7 @@ from control_backend.core.config import settings
|
||||
from control_backend.schemas.ri_message import SpeechCommand
|
||||
|
||||
|
||||
class ActSpeechAgent(BaseAgent):
|
||||
class RobotSpeechAgent(BaseAgent):
|
||||
subsocket: zmq.Socket
|
||||
pubsocket: zmq.Socket
|
||||
address = ""
|
||||
@@ -64,7 +64,7 @@ class ActSpeechAgent(BaseAgent):
|
||||
|
||||
async def setup(self):
|
||||
"""
|
||||
Setup the command agent
|
||||
Setup the robot speech command agent
|
||||
"""
|
||||
self.logger.info("Setting up %s", self.jid)
|
||||
|
||||
7
src/control_backend/agents/bdi/__init__.py
Normal file
7
src/control_backend/agents/bdi/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from .bdi_core_agent.bdi_core_agent import BDICoreAgent as BDICoreAgent
|
||||
from .belief_collector_agent.belief_collector_agent import (
|
||||
BDIBeliefCollectorAgent as BDIBeliefCollectorAgent,
|
||||
)
|
||||
from .text_belief_extractor_agent.text_belief_extractor_agent import (
|
||||
TextBeliefExtractorAgent as TextBeliefExtractorAgent,
|
||||
)
|
||||
@@ -57,7 +57,7 @@ class BDICoreAgent(BDIAgent):
|
||||
class SendBehaviour(OneShotBehaviour):
|
||||
async def run(self) -> None:
|
||||
msg = Message(
|
||||
to=settings.agent_settings.llm_agent_name + "@" + settings.agent_settings.host,
|
||||
to=settings.agent_settings.llm_name + "@" + settings.agent_settings.host,
|
||||
body=text,
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ class BeliefSetterBehaviour(CyclicBehaviour):
|
||||
self.agent.logger.debug("Processing message from sender: %s", sender)
|
||||
|
||||
match sender:
|
||||
case settings.agent_settings.bdi_belief_collector_agent_name:
|
||||
case settings.agent_settings.bdi_belief_collector_name:
|
||||
self.agent.logger.debug(
|
||||
"Message is from the belief collector agent. Processing as belief message."
|
||||
)
|
||||
@@ -15,14 +15,14 @@ class ReceiveLLMResponseBehaviour(CyclicBehaviour):
|
||||
|
||||
sender = msg.sender.node
|
||||
match sender:
|
||||
case settings.agent_settings.llm_agent_name:
|
||||
case settings.agent_settings.llm_name:
|
||||
content = msg.body
|
||||
self.agent.logger.info("Received LLM response: %s", content)
|
||||
|
||||
speech_command = SpeechCommand(data=content)
|
||||
|
||||
message = Message(
|
||||
to=settings.agent_settings.act_speech_agent_name
|
||||
to=settings.agent_settings.robot_speech_name
|
||||
+ "@"
|
||||
+ settings.agent_settings.host,
|
||||
sender=self.agent.jid,
|
||||
@@ -7,7 +7,7 @@ from spade.behaviour import CyclicBehaviour
|
||||
from control_backend.core.config import settings
|
||||
|
||||
|
||||
class BelCollectorBehaviour(CyclicBehaviour):
|
||||
class BeliefCollectorBehaviour(CyclicBehaviour):
|
||||
"""
|
||||
Continuously collects beliefs/emotions from extractor agents:
|
||||
Then we send a unified belief packet to the BDI agent.
|
||||
@@ -83,9 +83,7 @@ class BelCollectorBehaviour(CyclicBehaviour):
|
||||
if not beliefs:
|
||||
return
|
||||
|
||||
to_jid = (
|
||||
f"{settings.agent_settings.bdi_core_agent_agent_name}@{settings.agent_settings.host}"
|
||||
)
|
||||
to_jid = f"{settings.agent_settings.bdi_core_name}@{settings.agent_settings.host}"
|
||||
|
||||
msg = Message(to=to_jid, sender=self.agent.jid, thread="beliefs")
|
||||
msg.body = json.dumps(beliefs)
|
||||
@@ -1,11 +1,11 @@
|
||||
from control_backend.agents.base import BaseAgent
|
||||
|
||||
from .behaviours.bel_collector_behaviour import BelCollectorBehaviour
|
||||
from .behaviours.belief_collector_behaviour import BeliefCollectorBehaviour
|
||||
|
||||
|
||||
class BDIBeliefCollectorAgent(BaseAgent):
|
||||
async def setup(self):
|
||||
self.logger.info("BDIBeliefCollectorAgent starting (%s)", self.jid)
|
||||
# Attach the continuous collector behaviour (listens and forwards to BDI)
|
||||
self.add_behaviour(BelCollectorBehaviour())
|
||||
self.add_behaviour(BeliefCollectorBehaviour())
|
||||
self.logger.info("BDIBeliefCollectorAgent ready.")
|
||||
@@ -7,7 +7,7 @@ from spade.message import Message
|
||||
from control_backend.core.config import settings
|
||||
|
||||
|
||||
class BDITextBeliefBehaviour(CyclicBehaviour):
|
||||
class TextBeliefExtractorBehaviour(CyclicBehaviour):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# TODO: LLM prompt nog hardcoded
|
||||
@@ -44,7 +44,7 @@ class BDITextBeliefBehaviour(CyclicBehaviour):
|
||||
|
||||
sender = msg.sender.node
|
||||
match sender:
|
||||
case settings.agent_settings.per_transcription_agent_name:
|
||||
case settings.agent_settings.transcription_name:
|
||||
self.logger.debug("Received text from transcriber: %s", msg.body)
|
||||
await self._process_transcription_demo(msg.body)
|
||||
case _:
|
||||
@@ -71,7 +71,7 @@ class BDITextBeliefBehaviour(CyclicBehaviour):
|
||||
belief_message = Message()
|
||||
|
||||
belief_message.to = (
|
||||
settings.agent_settings.bdi_belief_collector_agent_name
|
||||
settings.agent_settings.bdi_belief_collector_name
|
||||
+ "@"
|
||||
+ settings.agent_settings.host
|
||||
)
|
||||
@@ -95,9 +95,7 @@ class BDITextBeliefBehaviour(CyclicBehaviour):
|
||||
belief_msg = Message()
|
||||
|
||||
belief_msg.to = (
|
||||
settings.agent_settings.bdi_belief_collector_agent_name
|
||||
+ "@"
|
||||
+ settings.agent_settings.host
|
||||
settings.agent_settings.bdi_belief_collector_name + "@" + settings.agent_settings.host
|
||||
)
|
||||
belief_msg.body = payload
|
||||
belief_msg.thread = "beliefs"
|
||||
@@ -0,0 +1,8 @@
|
||||
from control_backend.agents.base import BaseAgent
|
||||
|
||||
from .behaviours.text_belief_extractor_behaviour import TextBeliefExtractorBehaviour
|
||||
|
||||
|
||||
class TextBeliefExtractorAgent(BaseAgent):
|
||||
async def setup(self):
|
||||
self.add_behaviour(TextBeliefExtractorBehaviour())
|
||||
@@ -1,5 +0,0 @@
|
||||
from .bdi_belief_collector_agent.bel_collector_agent import (
|
||||
BDIBeliefCollectorAgent as BDIBeliefCollectorAgent,
|
||||
)
|
||||
from .bdi_core_agent.bdi_core_agent import BDICoreAgent as BDICoreAgent
|
||||
from .bdi_text_belief_agent.bdi_text_belief_agent import BDITextBeliefAgent as BDITextBeliefAgent
|
||||
@@ -1,8 +0,0 @@
|
||||
from control_backend.agents.base import BaseAgent
|
||||
|
||||
from .behaviours.bdi_text_belief_behaviour import BDITextBeliefBehaviour
|
||||
|
||||
|
||||
class BDITextBeliefAgent(BaseAgent):
|
||||
async def setup(self):
|
||||
self.add_behaviour(BDITextBeliefBehaviour())
|
||||
@@ -1 +0,0 @@
|
||||
from .com_ri_agent import ComRIAgent as ComRIAgent
|
||||
1
src/control_backend/agents/communication/__init__.py
Normal file
1
src/control_backend/agents/communication/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .ri_communication_agent import RICommunicationAgent as RICommunicationAgent
|
||||
@@ -8,10 +8,10 @@ from zmq.asyncio import Context
|
||||
from control_backend.agents import BaseAgent
|
||||
from control_backend.core.config import settings
|
||||
|
||||
from ..act_agents.act_speech_agent import ActSpeechAgent
|
||||
from ..actuation.robot_speech_agent import RobotSpeechAgent
|
||||
|
||||
|
||||
class ComRIAgent(BaseAgent):
|
||||
class RICommunicationAgent(BaseAgent):
|
||||
req_socket: zmq.Socket
|
||||
_address = ""
|
||||
_bind = True
|
||||
@@ -204,11 +204,11 @@ class ComRIAgent(BaseAgent):
|
||||
else:
|
||||
self._req_socket.bind(addr)
|
||||
case "actuation":
|
||||
ri_commands_agent = ActSpeechAgent(
|
||||
settings.agent_settings.act_speech_agent_name
|
||||
ri_commands_agent = RobotSpeechAgent(
|
||||
settings.agent_settings.robot_speech_name
|
||||
+ "@"
|
||||
+ settings.agent_settings.host,
|
||||
settings.agent_settings.act_speech_agent_name,
|
||||
settings.agent_settings.robot_speech_name,
|
||||
address=addr,
|
||||
bind=bind,
|
||||
)
|
||||
@@ -39,7 +39,7 @@ class LLMAgent(BaseAgent):
|
||||
sender,
|
||||
)
|
||||
|
||||
if sender == settings.agent_settings.bdi_core_agent_agent_name:
|
||||
if sender == settings.agent_settings.bdi_core_name:
|
||||
self.agent.logger.debug("Processing message from BDI Core Agent")
|
||||
await self._process_bdi_message(msg)
|
||||
else:
|
||||
@@ -63,9 +63,7 @@ class LLMAgent(BaseAgent):
|
||||
Sends a response message back to the BDI Core Agent.
|
||||
"""
|
||||
reply = Message(
|
||||
to=settings.agent_settings.bdi_core_agent_agent_name
|
||||
+ "@"
|
||||
+ settings.agent_settings.host,
|
||||
to=settings.agent_settings.bdi_core_name + "@" + settings.agent_settings.host,
|
||||
body=msg,
|
||||
)
|
||||
await self.send(reply)
|
||||
@@ -1,44 +0,0 @@
|
||||
import json
|
||||
|
||||
from spade.agent import Agent
|
||||
from spade.behaviour import OneShotBehaviour
|
||||
from spade.message import Message
|
||||
|
||||
from control_backend.core.config import settings
|
||||
|
||||
|
||||
class BelTextAgent(Agent):
|
||||
class SendOnceBehaviourBlfText(OneShotBehaviour):
|
||||
async def run(self):
|
||||
to_jid = (
|
||||
settings.agent_settings.bdi_belief_collector_agent_name
|
||||
+ "@"
|
||||
+ settings.agent_settings.host
|
||||
)
|
||||
|
||||
# Send multiple beliefs in one JSON payload
|
||||
payload = {
|
||||
"type": "belief_extraction_text",
|
||||
"beliefs": {
|
||||
"user_said": [
|
||||
"hello test",
|
||||
"Can you help me?",
|
||||
"stop talking to me",
|
||||
"No",
|
||||
"Pepper do a dance",
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
msg = Message(to=to_jid)
|
||||
msg.body = json.dumps(payload)
|
||||
await self.send(msg)
|
||||
print(f"Beliefs sent to {to_jid}!")
|
||||
|
||||
self.exit_code = "Job Finished!"
|
||||
await self.agent.stop()
|
||||
|
||||
async def setup(self):
|
||||
print("BelTextAgent started")
|
||||
self.b = self.SendOnceBehaviourBlfText()
|
||||
self.add_behaviour(self.b)
|
||||
@@ -1,4 +0,0 @@
|
||||
from .per_transcription_agent.per_transcription_agent import (
|
||||
PerTranscriptionAgent as PerTranscriptionAgent,
|
||||
)
|
||||
from .per_vad_agent import PerVADAgent as PerVADAgent
|
||||
4
src/control_backend/agents/perception/__init__.py
Normal file
4
src/control_backend/agents/perception/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from .transcription_agent.transcription_agent import (
|
||||
TranscriptionAgent as TranscriptionAgent,
|
||||
)
|
||||
from .vad_agent import VADAgent as VADAgent
|
||||
@@ -12,24 +12,20 @@ from control_backend.core.config import settings
|
||||
from .speech_recognizer import SpeechRecognizer
|
||||
|
||||
|
||||
class PerTranscriptionAgent(BaseAgent):
|
||||
class TranscriptionAgent(BaseAgent):
|
||||
"""
|
||||
An agent which listens to audio fragments with voice, transcribes them, and sends the
|
||||
transcription to other agents.
|
||||
"""
|
||||
|
||||
def __init__(self, audio_in_address: str):
|
||||
jid = (
|
||||
settings.agent_settings.per_transcription_agent_name
|
||||
+ "@"
|
||||
+ settings.agent_settings.host
|
||||
)
|
||||
super().__init__(jid, settings.agent_settings.per_transcription_agent_name)
|
||||
jid = settings.agent_settings.transcription_name + "@" + settings.agent_settings.host
|
||||
super().__init__(jid, settings.agent_settings.transcription_name)
|
||||
|
||||
self.audio_in_address = audio_in_address
|
||||
self.audio_in_socket: azmq.Socket | None = None
|
||||
|
||||
class Transcribing(CyclicBehaviour):
|
||||
class TranscribingBehaviour(CyclicBehaviour):
|
||||
def __init__(self, audio_in_socket: azmq.Socket):
|
||||
super().__init__()
|
||||
self.audio_in_socket = audio_in_socket
|
||||
@@ -83,7 +79,7 @@ class PerTranscriptionAgent(BaseAgent):
|
||||
|
||||
self._connect_audio_in_socket()
|
||||
|
||||
transcribing = self.Transcribing(self.audio_in_socket)
|
||||
transcribing = self.TranscribingBehaviour(self.audio_in_socket)
|
||||
transcribing.warmup()
|
||||
self.add_behaviour(transcribing)
|
||||
|
||||
@@ -7,7 +7,7 @@ from spade.behaviour import CyclicBehaviour
|
||||
from control_backend.agents import BaseAgent
|
||||
from control_backend.core.config import settings
|
||||
|
||||
from .per_transcription_agent.per_transcription_agent import PerTranscriptionAgent
|
||||
from .transcription_agent.transcription_agent import TranscriptionAgent
|
||||
|
||||
|
||||
class SocketPoller[T]:
|
||||
@@ -40,7 +40,7 @@ class SocketPoller[T]:
|
||||
return None
|
||||
|
||||
|
||||
class Streaming(CyclicBehaviour):
|
||||
class StreamingBehaviour(CyclicBehaviour):
|
||||
def __init__(self, audio_in_socket: azmq.Socket, audio_out_socket: azmq.Socket):
|
||||
super().__init__()
|
||||
self.audio_in_poller = SocketPoller[bytes](audio_in_socket)
|
||||
@@ -102,15 +102,15 @@ class Streaming(CyclicBehaviour):
|
||||
self.audio_buffer = chunk
|
||||
|
||||
|
||||
class PerVADAgent(BaseAgent):
|
||||
class VADAgent(BaseAgent):
|
||||
"""
|
||||
An agent which listens to an audio stream, does Voice Activity Detection (VAD), and sends
|
||||
fragments with detected speech to other agents over ZeroMQ.
|
||||
"""
|
||||
|
||||
def __init__(self, audio_in_address: str, audio_in_bind: bool):
|
||||
jid = settings.agent_settings.per_vad_agent_name + "@" + settings.agent_settings.host
|
||||
super().__init__(jid, settings.agent_settings.per_vad_agent_name)
|
||||
jid = settings.agent_settings.vad_name + "@" + settings.agent_settings.host
|
||||
super().__init__(jid, settings.agent_settings.vad_name)
|
||||
|
||||
self.audio_in_address = audio_in_address
|
||||
self.audio_in_bind = audio_in_bind
|
||||
@@ -118,7 +118,7 @@ class PerVADAgent(BaseAgent):
|
||||
self.audio_in_socket: azmq.Socket | None = None
|
||||
self.audio_out_socket: azmq.Socket | None = None
|
||||
|
||||
self.streaming_behaviour: Streaming | None = None
|
||||
self.streaming_behaviour: StreamingBehaviour | None = None
|
||||
|
||||
async def stop(self):
|
||||
"""
|
||||
@@ -162,11 +162,11 @@ class PerVADAgent(BaseAgent):
|
||||
return
|
||||
audio_out_address = f"tcp://localhost:{audio_out_port}"
|
||||
|
||||
self.streaming_behaviour = Streaming(self.audio_in_socket, self.audio_out_socket)
|
||||
self.streaming_behaviour = StreamingBehaviour(self.audio_in_socket, self.audio_out_socket)
|
||||
self.add_behaviour(self.streaming_behaviour)
|
||||
|
||||
# Start agents dependent on the output audio fragments here
|
||||
transcriber = PerTranscriptionAgent(audio_out_address)
|
||||
transcriber = TranscriptionAgent(audio_out_address)
|
||||
await transcriber.start()
|
||||
|
||||
self.logger.info("Finished setting up %s", self.jid)
|
||||
@@ -9,16 +9,16 @@ class ZMQSettings(BaseModel):
|
||||
|
||||
class AgentSettings(BaseModel):
|
||||
host: str = "localhost"
|
||||
bdi_core_agent_agent_name: str = "bdi_core_agent"
|
||||
bdi_belief_collector_agent_name: str = "bdi_belief_collector_agent"
|
||||
bdi_text_belief_agent_name: str = "bdi_text_belief_agent"
|
||||
per_vad_agent_name: str = "per_vad_agent"
|
||||
llm_agent_name: str = "llm_agent"
|
||||
test_agent_name: str = "test_agent"
|
||||
per_transcription_agent_name: str = "per_transcription_agent"
|
||||
bdi_core_name: str = "bdi_core_agent"
|
||||
bdi_belief_collector_name: str = "belief_collector_agent"
|
||||
text_belief_extractor_name: str = "text_belief_extractor_agent"
|
||||
vad_name: str = "vad_agent"
|
||||
llm_name: str = "llm_agent"
|
||||
test_name: str = "test_agent"
|
||||
transcription_name: str = "transcription_agent"
|
||||
|
||||
com_ri_agent_name: str = "com_ri_agent"
|
||||
act_speech_agent_name: str = "act_speech_agent"
|
||||
ri_communication_name: str = "ri_communication_agent"
|
||||
robot_speech_name: str = "robot_speech_agent"
|
||||
|
||||
|
||||
class LLMSettings(BaseModel):
|
||||
|
||||
@@ -9,21 +9,21 @@ from zmq.asyncio import Context
|
||||
|
||||
# Act agents
|
||||
# BDI agents
|
||||
from control_backend.agents.bdi_agents import (
|
||||
from control_backend.agents.bdi import (
|
||||
BDIBeliefCollectorAgent,
|
||||
BDICoreAgent,
|
||||
BDITextBeliefAgent,
|
||||
TextBeliefExtractorAgent,
|
||||
)
|
||||
|
||||
# Communication agents
|
||||
from control_backend.agents.com_agents import ComRIAgent
|
||||
from control_backend.agents.communication import RICommunicationAgent
|
||||
|
||||
# Emotional Agents
|
||||
# LLM Agents
|
||||
from control_backend.agents.llm_agents import LLMAgent
|
||||
from control_backend.agents.llm import LLMAgent
|
||||
|
||||
# Perceive agents
|
||||
from control_backend.agents.per_agents import PerVADAgent
|
||||
from control_backend.agents.perception import VADAgent
|
||||
|
||||
# Other backend imports
|
||||
from control_backend.api.v1.router import api_router
|
||||
@@ -77,12 +77,12 @@ async def lifespan(app: FastAPI):
|
||||
logger.info("Initializing and starting agents.")
|
||||
agents_to_start = {
|
||||
"ComRIAgent": (
|
||||
ComRIAgent,
|
||||
RICommunicationAgent,
|
||||
{
|
||||
"name": settings.agent_settings.com_ri_agent_name,
|
||||
"jid": f"{settings.agent_settings.com_ri_agent_name}"
|
||||
"name": settings.agent_settings.ri_communication_name,
|
||||
"jid": f"{settings.agent_settings.ri_communication_name}"
|
||||
f"@{settings.agent_settings.host}",
|
||||
"password": settings.agent_settings.com_ri_agent_name,
|
||||
"password": settings.agent_settings.ri_communication_name,
|
||||
"address": "tcp://*:5555",
|
||||
"bind": True,
|
||||
},
|
||||
@@ -90,56 +90,61 @@ async def lifespan(app: FastAPI):
|
||||
"LLMAgent": (
|
||||
LLMAgent,
|
||||
{
|
||||
"name": settings.agent_settings.llm_agent_name,
|
||||
"jid": f"{settings.agent_settings.llm_agent_name}@{settings.agent_settings.host}",
|
||||
"password": settings.agent_settings.llm_agent_name,
|
||||
"name": settings.agent_settings.llm_name,
|
||||
"jid": f"{settings.agent_settings.llm_name}@{settings.agent_settings.host}",
|
||||
"password": settings.agent_settings.llm_name,
|
||||
},
|
||||
),
|
||||
"BDICoreAgent": (
|
||||
BDICoreAgent,
|
||||
{
|
||||
"name": settings.agent_settings.bdi_core_agent_agent_name,
|
||||
"jid": f"{settings.agent_settings.bdi_core_agent_agent_name}@"
|
||||
f"{settings.agent_settings.host}",
|
||||
"password": settings.agent_settings.bdi_core_agent_agent_name,
|
||||
"asl": "src/control_backend/agents/bdi_agents/bdi_core_agent/rules.asl",
|
||||
"name": settings.agent_settings.bdi_core_name,
|
||||
"jid": f"{settings.agent_settings.bdi_core_name}@{settings.agent_settings.host}",
|
||||
"password": settings.agent_settings.bdi_core_name,
|
||||
"asl": "src/control_backend/agents/bdi/bdi_core_agent/rules.asl",
|
||||
},
|
||||
),
|
||||
"BDIBeliefCollectorAgent": (
|
||||
BDIBeliefCollectorAgent,
|
||||
{
|
||||
"name": settings.agent_settings.bdi_belief_collector_agent_name,
|
||||
"jid": f"{settings.agent_settings.bdi_belief_collector_agent_name}@"
|
||||
"name": settings.agent_settings.bdi_belief_collector_name,
|
||||
"jid": f"{settings.agent_settings.bdi_belief_collector_name}@"
|
||||
f"{settings.agent_settings.host}",
|
||||
"password": settings.agent_settings.bdi_belief_collector_agent_name,
|
||||
"password": settings.agent_settings.bdi_belief_collector_name,
|
||||
},
|
||||
),
|
||||
"BDITextBeliefAgent": (
|
||||
BDITextBeliefAgent,
|
||||
TextBeliefExtractorAgent,
|
||||
{
|
||||
"name": settings.agent_settings.bdi_text_belief_agent_name,
|
||||
"jid": f"{settings.agent_settings.bdi_text_belief_agent_name}@"
|
||||
"name": settings.agent_settings.text_belief_extractor_name,
|
||||
"jid": f"{settings.agent_settings.text_belief_extractor_name}@"
|
||||
f"{settings.agent_settings.host}",
|
||||
"password": settings.agent_settings.bdi_text_belief_agent_name,
|
||||
"password": settings.agent_settings.text_belief_extractor_name,
|
||||
},
|
||||
),
|
||||
"PerVADAgent": (
|
||||
PerVADAgent,
|
||||
VADAgent,
|
||||
{"audio_in_address": "tcp://localhost:5558", "audio_in_bind": False},
|
||||
),
|
||||
}
|
||||
|
||||
vad_agent = None
|
||||
|
||||
for name, (agent_class, kwargs) in agents_to_start.items():
|
||||
try:
|
||||
logger.debug("Starting agent: %s", name)
|
||||
agent_instance = agent_class(**{k: v for k, v in kwargs.items() if k != "name"})
|
||||
await agent_instance.start()
|
||||
if isinstance(agent_instance, VADAgent):
|
||||
vad_agent = agent_instance
|
||||
logger.info("Agent '%s' started successfully.", name)
|
||||
except Exception as e:
|
||||
logger.error("Failed to start agent '%s': %s", name, e, exc_info=True)
|
||||
# Consider if the application should continue if an agent fails to start.
|
||||
raise
|
||||
|
||||
await vad_agent.streaming_behaviour.reset()
|
||||
|
||||
logger.info("Application startup complete.")
|
||||
|
||||
yield
|
||||
|
||||
Reference in New Issue
Block a user