Skip to content

Commit b5017ea

Browse files
Added A2A platform and bug fixes in DB monitoring
Adding A2A platform and bug fixes in DB monitoring A2A platform. 1. Updated Agent class to include A2A as a platform. 2. Implemented A2A as a platform that depedends on BAF's functionality. 3. Created server, agent-card, message router, agent and method registration. 4. Added a test script in examples to test A2A protocol.
1 parent 5b172b3 commit b5017ea

34 files changed

+1690
-7
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[![PyPI - License](https://img.shields.io/pypi/l/besser-agentic-framework)](https://opensource.org/license/MIT)
1010
[![LinkedIn](https://img.shields.io/badge/-LinkedIn-blue?logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/pireseduardo/)](https://www.linkedin.com/company/besser-agentic-framework)
1111
[![GitHub Repo stars](https://img.shields.io/github/stars/besser-pearl/besser-agentic-framework?style=social)](https://star-history.com/#besser-pearl/besser-agentic-framework)
12+
[![SWH](https://archive.softwareheritage.org/badge/origin/https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/)](https://archive.softwareheritage.org/browse/origin/?origin_url=https://github.com/BESSER-PEARL/BESSER-Agentic-Framework)
1213

1314
The BESSER Agentic Framework (BAF) is part of the [BESSER](https://modeling-languages.com/a-smart-low-code-platform-for-smart-software-in-luxembourg-goodbye-barcelona/) (Building Better Smart Software Faster) project. It aims
1415
to make the design and implementation of agents, bots and chatbots easier and accessible for everyone.
@@ -69,5 +70,6 @@ Note that if you want to set your agent's language to **Luxembourgish**, you wil
6970
- [telegram_agent](https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/test/examples/telegram_agent.py): Introducing the [TelegramPlatform](https://besser-agentic-framework.readthedocs.io/latest/wiki/platforms/telegram_platform.html)
7071
- [github_agent](https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/test/examples/github_agent.py): Introducing [GitHubPlatform](https://besser-agentic-framework.readthedocs.io/latest/wiki/platforms/github_platform.html)
7172
- [gitlab_agent](https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/test/examples/gitlab_agent.py): Introducing the [GitLabPlatform](https://besser-agentic-framework.readthedocs.io/latest/wiki/platforms/gitlab_platform.html)
73+
- [a2a_multiagent](https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/test/examples/a2a_multiagent.py): Introducing the [A2APlatform](https://besser-agentic-framework.readthedocs.io/latest/wiki/platforms/a2a_platform.html)
7274

7375
For more example agents, check out the [BAF-agent-examples](https://github.com/BESSER-PEARL/BAF-agent-examples) repository!

besser/agent/core/agent.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from besser.agent.platforms.websocket.websocket_platform import WebSocketPlatform
3131
from besser.agent.platforms.github.github_platform import GitHubPlatform
3232
from besser.agent.platforms.gitlab.gitlab_platform import GitLabPlatform
33+
from besser.agent.platforms.a2a.a2a_platform import A2APlatform
3334

3435

3536
class Agent:
@@ -528,6 +529,16 @@ def use_gitlab_platform(self) -> GitLabPlatform:
528529
gitlab_platform = GitLabPlatform(self)
529530
self._platforms.append(gitlab_platform)
530531
return gitlab_platform
532+
533+
def use_a2a_platform(self) -> A2APlatform:
534+
"""Use the :class: `~besser.agent.platforms.a2a.a2a_platform.A2APlatform` on this agent.
535+
536+
Returns:
537+
A2APlatform: the A2A platform
538+
"""
539+
a2a_platform = A2APlatform(self)
540+
self._platforms.append(a2a_platform)
541+
return a2a_platform
531542

532543
def _monitoring_db_insert_session(self, session: Session) -> None:
533544
"""Insert a session record into the monitoring database.

besser/agent/db/monitoring_ui/flow_graph.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@
33
from pyvis.network import Network
44

55
from besser.agent.db.monitoring_db import MonitoringDB, TABLE_TRANSITION, TABLE_SESSION
6-
from besser.agent.db.monitoring_ui.home import agent_filter
6+
from besser.agent.db.monitoring_ui.home import agent_filter, session_filter
77

88

99
def flow_graph(monitoring_db: MonitoringDB):
1010
st.header('Flow Graph')
1111
agent_names = agent_filter(monitoring_db)
1212
table_transition = monitoring_db.get_table(TABLE_TRANSITION)
13+
table_session = monitoring_db.get_table(TABLE_SESSION)
1314
if agent_names:
14-
table_session = monitoring_db.get_table(TABLE_SESSION)
1515
# Filter the tables by the specified agents
1616
table_session = table_session[table_session['agent_name'].isin(agent_names)]
1717
table_transition = table_transition[table_transition['session_id'].isin(table_session['id'])]
18+
19+
session_ids = session_filter(monitoring_db)
20+
if session_ids:
21+
# Filter the tables by the specified sessions
22+
table_session = table_session[table_session['session_id'].isin(session_ids)]
23+
table_transition = table_transition[table_transition['session_id'].isin(table_session['id'])]
1824

1925
nt = Network("700px", "100%", notebook=True, directed=True)
2026
state_set = set()
@@ -37,6 +43,9 @@ def flow_graph(monitoring_db: MonitoringDB):
3743
if source_state not in state_set:
3844
state_set.add(source_state)
3945
nt.add_node(source_state, group=1)
46+
if dest_state not in state_set:
47+
state_set.add(dest_state)
48+
nt.add_node(dest_state, group=1)
4049
if (source_state, dest_state, event, info) not in transition_dict:
4150
transition_dict[(source_state, dest_state, event, info)] = 1
4251
else:

besser/agent/db/monitoring_ui/home.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ def agent_filter(monitoring_db: MonitoringDB):
7272
agent_names = st.multiselect(label='Select one or more agents', options=agents, placeholder='All agents')
7373
return agent_names
7474

75+
def session_filter(monitoring_db: MonitoringDB):
76+
sessions = monitoring_db.get_table(TABLE_SESSION)['session_id'].unique()
77+
session_ids = st.multiselect(label='Select one or more sessions', options=sessions, placeholder='All sessions')
78+
return session_ids
79+
7580

7681
def get_matched_intents_ratio(monitoring_db: MonitoringDB, agent_names=[]):
7782
table_intent_prediction = monitoring_db.get_table(TABLE_INTENT_PREDICTION)

besser/agent/nlp/nlp_engine.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,12 @@ def text2speech(self, session: Session, text: str):
232232
233233
Returns:
234234
dict: the speech synthesis as a dictionary containing 2 keys:
235+
235236
- audio (np.ndarray): the generated audio waveform as a numpy array with dimensions (nb_channels,
236-
audio_length), where nb_channels is the number of audio channels (usually 1 for mono) and audio_length is the number
237-
of samples in the audio
237+
audio_length), where nb_channels is the number of audio channels (usually 1 for mono) and audio_length is the number
238+
of samples in the audio
238239
- sampling_rate (int): an integer value containing the sampling rate, eg. how many samples correspond to
239-
one second of audio
240+
one second of audio
240241
"""
241242

242243
user_language = session.get("user_language", "en")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""Definition of the agent properties within the ``A2A_platform`` section:"""
2+
3+
from besser.agent.core.property import Property
4+
5+
SECTION_A2A = 'a2a_platform'
6+
7+
A2A_WEBSOCKET_PORT = Property(SECTION_A2A, 'a2a.port', int, 8000)
8+
"""
9+
The server local port. This port should be exposed or proxied to make it visible by other Agents
10+
11+
name: ``a2a.port``
12+
13+
type: ``int``
14+
15+
default value: ``8000``
16+
"""

0 commit comments

Comments
 (0)