Create transcriber agent #15
@@ -31,9 +31,6 @@ class BDICoreAgent(BDIAgent):
|
|||||||
self.add_behaviour(BeliefSetterBehaviour())
|
self.add_behaviour(BeliefSetterBehaviour())
|
||||||
self.add_behaviour(ReceiveLLMResponseBehaviour())
|
self.add_behaviour(ReceiveLLMResponseBehaviour())
|
||||||
|
|
||||||
await self._send_to_llm("Hi pepper, how are you?")
|
|
||||||
# This is the example message currently sent to the llm at the start of the Program
|
|
||||||
|
|
||||||
self.logger.info("BDICoreAgent setup complete")
|
self.logger.info("BDICoreAgent setup complete")
|
||||||
|
|
||||||
def add_custom_actions(self, actions) -> None:
|
def add_custom_actions(self, actions) -> None:
|
||||||
@@ -50,10 +47,10 @@ class BDICoreAgent(BDIAgent):
|
|||||||
message_text = agentspeak.grounded(term.args[0], intention.scope)
|
message_text = agentspeak.grounded(term.args[0], intention.scope)
|
||||||
self.logger.info("Reply action sending: %s", message_text)
|
self.logger.info("Reply action sending: %s", message_text)
|
||||||
|
|
||||||
self._send_to_llm(message_text)
|
self._send_to_llm(str(message_text))
|
||||||
yield
|
yield
|
||||||
|
|
||||||
async def _send_to_llm(self, text: str):
|
def _send_to_llm(self, text: str):
|
||||||
"""
|
"""
|
||||||
Sends a text query to the LLM Agent asynchronously.
|
Sends a text query to the LLM Agent asynchronously.
|
||||||
"""
|
"""
|
||||||
@@ -66,6 +63,6 @@ class BDICoreAgent(BDIAgent):
|
|||||||
)
|
)
|
||||||
|
|
||||||
await self.send(msg)
|
await self.send(msg)
|
||||||
self.agent.logger.debug("Message sent to LLM: %s", text)
|
self.agent.logger.info("Message sent to LLM: %s", text)
|
||||||
|
|
||||||
self.add_behaviour(SendBehaviour())
|
self.add_behaviour(SendBehaviour())
|
||||||
@@ -61,10 +61,6 @@ class BeliefSetterBehaviour(CyclicBehaviour):
|
|||||||
self.agent.bdi.set_belief(belief, *arguments)
|
self.agent.bdi.set_belief(belief, *arguments)
|
||||||
|
|
||||||
# Special case: if there's a new user message, flag that we haven't responded yet
|
# Special case: if there's a new user message, flag that we haven't responded yet
|
||||||
if belief == "user_said":
|
if belief == "user_said": self.agent.bdi.set_belief("new_message")
|
||||||
try:
|
|
||||||
self.agent.bdi.remove_belief("responded")
|
|
||||||
except BeliefNotInitiated:
|
|
||||||
pass
|
|
||||||
|
|
||||||
self.logger.info("Set belief %s with arguments %s", belief, arguments)
|
self.logger.info("Set belief %s with arguments %s", belief, arguments)
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ class BeliefFromText(CyclicBehaviour):
|
|||||||
if msg:
|
if msg:
|
||||||
sender = msg.sender.node
|
sender = msg.sender.node
|
||||||
match sender:
|
match sender:
|
||||||
# TODO: Change to Transcriber agent name once implemented
|
case settings.agent_settings.transcription_agent_name:
|
||||||
case settings.agent_settings.test_agent_name:
|
|
||||||
self.logger.info("Received text from transcriber.")
|
self.logger.info("Received text from transcriber.")
|
||||||
await self._process_transcription_demo(msg.body)
|
await self._process_transcription_demo(msg.body)
|
||||||
case _:
|
case _:
|
||||||
@@ -84,10 +83,9 @@ class BeliefFromText(CyclicBehaviour):
|
|||||||
'user_said' is relevant, so this function simply makes a dict with key: "user_said",
|
'user_said' is relevant, so this function simply makes a dict with key: "user_said",
|
||||||
value: txt and passes this to the Belief Collector agent.
|
value: txt and passes this to the Belief Collector agent.
|
||||||
"""
|
"""
|
||||||
belief = {"user_said": [txt]}
|
belief = {"beliefs": {"user_said": [txt]}, "type": "belief_extraction_text"}
|
||||||
payload = json.dumps(belief)
|
payload = json.dumps(belief)
|
||||||
# TODO: Change to belief collector
|
belief_msg = Message(to=settings.agent_settings.belief_collector_agent_name
|
||||||
belief_msg = Message(to=settings.agent_settings.bdi_core_agent_name
|
|
||||||
+ '@' + settings.agent_settings.host,
|
+ '@' + settings.agent_settings.host,
|
||||||
body=payload)
|
body=payload)
|
||||||
belief_msg.thread = "beliefs"
|
belief_msg.thread = "beliefs"
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
+user_said(Message) : not responded <-
|
+new_message : user_said(Message) <-
|
||||||
+responded;
|
-new_message;
|
||||||
.reply(Message).
|
.reply(Message).
|
||||||
|
|||||||
@@ -104,14 +104,8 @@ class ContinuousBeliefCollector(CyclicBehaviour):
|
|||||||
|
|
||||||
to_jid = f"{settings.agent_settings.bdi_core_agent_name}@{settings.agent_settings.host}"
|
to_jid = f"{settings.agent_settings.bdi_core_agent_name}@{settings.agent_settings.host}"
|
||||||
|
|
||||||
packet = {
|
msg = Message(to=to_jid, sender=self.agent.jid, thread="beliefs")
|
||||||
"type": "belief_packet",
|
msg.body = json.dumps(beliefs)
|
||||||
"origin": origin,
|
|
||||||
"beliefs": beliefs,
|
|
||||||
}
|
|
||||||
|
|
||||||
msg = Message(to=to_jid)
|
|
||||||
msg.body = json.dumps(packet)
|
|
||||||
|
|
||||||
|
|
||||||
await self.send(msg)
|
await self.send(msg)
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ class MLXWhisperSpeechRecognizer(SpeechRecognizer):
|
|||||||
return mlx_whisper.transcribe(audio,
|
return mlx_whisper.transcribe(audio,
|
||||||
path_or_hf_repo=self.model_name,
|
path_or_hf_repo=self.model_name,
|
||||||
decode_options=self._get_decode_options(audio))["text"]
|
decode_options=self._get_decode_options(audio))["text"]
|
||||||
|
return mlx_whisper.transcribe(audio, path_or_hf_repo=self.model_name)["text"].strip()
|
||||||
|
|
||||||
|
|
||||||
class OpenAIWhisperSpeechRecognizer(SpeechRecognizer):
|
class OpenAIWhisperSpeechRecognizer(SpeechRecognizer):
|
||||||
|
|||||||
@@ -45,7 +45,10 @@ class TranscriptionAgent(Agent):
|
|||||||
|
|
||||||
async def _share_transcription(self, transcription: str):
|
async def _share_transcription(self, transcription: str):
|
||||||
"""Share a transcription to the other agents that depend on it."""
|
"""Share a transcription to the other agents that depend on it."""
|
||||||
receiver_jids = [] # Set message receivers here
|
receiver_jids = [
|
||||||
|
settings.agent_settings.text_belief_extractor_agent_name
|
||||||
|
+ '@' + settings.agent_settings.host,
|
||||||
|
] # Set message receivers here
|
||||||
|
|
||||||
for receiver_jid in receiver_jids:
|
for receiver_jid in receiver_jids:
|
||||||
message = Message(to=receiver_jid, body=transcription)
|
message = Message(to=receiver_jid, body=transcription)
|
||||||
|
|||||||
Reference in New Issue
Block a user