distributed-a2a 0.1.5__py3-none-any.whl → 0.1.5rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- distributed_a2a/agent.py +9 -19
- distributed_a2a/executors.py +3 -4
- distributed_a2a/model.py +22 -31
- distributed_a2a/server.py +9 -10
- {distributed_a2a-0.1.5.dist-info → distributed_a2a-0.1.5rc1.dist-info}/METADATA +1 -2
- distributed_a2a-0.1.5rc1.dist-info/RECORD +12 -0
- distributed_a2a-0.1.5.dist-info/RECORD +0 -12
- {distributed_a2a-0.1.5.dist-info → distributed_a2a-0.1.5rc1.dist-info}/WHEEL +0 -0
- {distributed_a2a-0.1.5.dist-info → distributed_a2a-0.1.5rc1.dist-info}/licenses/LICENSE +0 -0
- {distributed_a2a-0.1.5.dist-info → distributed_a2a-0.1.5rc1.dist-info}/top_level.txt +0 -0
distributed_a2a/agent.py
CHANGED
|
@@ -4,10 +4,10 @@ from a2a.types import TaskState
|
|
|
4
4
|
from langchain.agents import create_agent
|
|
5
5
|
from langchain_core.runnables import RunnableConfig
|
|
6
6
|
from langchain_core.tools import BaseTool
|
|
7
|
-
from
|
|
7
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
8
8
|
from pydantic import BaseModel, Field
|
|
9
9
|
|
|
10
|
-
from .model import get_model, AgentConfig
|
|
10
|
+
from .model import get_model, AgentConfig
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class AgentResponse(BaseModel):
|
|
@@ -20,42 +20,32 @@ class AgentResponse(BaseModel):
|
|
|
20
20
|
)
|
|
21
21
|
)
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
class RoutingResponse(AgentResponse):
|
|
25
24
|
agent_card: str = Field(description="The stringified json of the agent card to be returned to the user")
|
|
26
25
|
|
|
27
|
-
|
|
28
26
|
class StringResponse(AgentResponse):
|
|
29
27
|
response: str = Field(description="The main response to be returned to the user")
|
|
30
28
|
|
|
31
29
|
|
|
32
30
|
class StatusAgent[ResponseT: AgentResponse]:
|
|
33
31
|
|
|
34
|
-
def __init__(self,
|
|
35
|
-
tools: list[BaseTool]):
|
|
32
|
+
def __init__(self, agent_config: AgentConfig, api_key: str, is_routing: bool, tools: list[BaseTool]):
|
|
36
33
|
response_format: type[AgentResponse]
|
|
37
34
|
if is_routing:
|
|
38
35
|
response_format = RoutingResponse
|
|
39
36
|
else:
|
|
40
37
|
response_format = StringResponse
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
saver = DynamoDBSaver(
|
|
44
|
-
table_name=f"checkpoint_saver_{name}",
|
|
45
|
-
max_read_request_units=20, ## TODO find correct value for app
|
|
46
|
-
max_write_request_units=20, ## TODO find correct value for app
|
|
47
|
-
ttl_seconds=86400
|
|
48
|
-
)
|
|
49
39
|
self.agent = create_agent(
|
|
50
40
|
get_model(api_key=api_key,
|
|
51
|
-
model=
|
|
52
|
-
base_url=
|
|
53
|
-
reasoning_effort=
|
|
41
|
+
model=agent_config.agent.llm.model,
|
|
42
|
+
base_url=agent_config.agent.llm.base_url,
|
|
43
|
+
reasoning_effort=agent_config.agent.llm.reasoning_effort),
|
|
54
44
|
tools=tools,
|
|
55
|
-
checkpointer=
|
|
56
|
-
system_prompt=system_prompt,
|
|
45
|
+
checkpointer=MemorySaver(), # TODO replace by dynamodb
|
|
46
|
+
system_prompt=agent_config.agent.llm.system_prompt,
|
|
57
47
|
response_format=response_format,
|
|
58
|
-
name=name
|
|
48
|
+
name=agent_config.agent.card.name
|
|
59
49
|
)
|
|
60
50
|
|
|
61
51
|
async def __call__(self, message: str, context_id: str = None) -> ResponseT:
|
distributed_a2a/executors.py
CHANGED
|
@@ -7,6 +7,7 @@ from a2a.server.events import EventQueue
|
|
|
7
7
|
from a2a.types import TaskStatusUpdateEvent, TaskStatus, TaskState, TaskArtifactUpdateEvent, Artifact
|
|
8
8
|
from a2a.utils import new_text_artifact
|
|
9
9
|
from langchain_core.tools import BaseTool
|
|
10
|
+
from openai import api_key
|
|
10
11
|
|
|
11
12
|
from .agent import StatusAgent, RoutingResponse, StringResponse
|
|
12
13
|
from .model import AgentConfig
|
|
@@ -26,15 +27,13 @@ class RoutingAgentExecutor(AgentExecutor):
|
|
|
26
27
|
super().__init__()
|
|
27
28
|
api_key = os.environ.get(agent_config.agent.llm.api_key_env)
|
|
28
29
|
self.agent = StatusAgent[StringResponse](
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
name=agent_config.agent.card.name,
|
|
30
|
+
system_prompt=agent_config.agent.llm.system_prompt,
|
|
31
|
+
name="Router",
|
|
32
32
|
api_key=api_key,
|
|
33
33
|
is_routing=False,
|
|
34
34
|
tools=[] if tools is None else tools,
|
|
35
35
|
)
|
|
36
36
|
self.routing_agent = StatusAgent[RoutingResponse](
|
|
37
|
-
llm_config=agent_config.agent.llm,
|
|
38
37
|
system_prompt=ROUTING_SYSTEM_PROMPT,
|
|
39
38
|
name="Router",
|
|
40
39
|
api_key=api_key,
|
distributed_a2a/model.py
CHANGED
|
@@ -1,52 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
from typing import List, Any
|
|
1
|
+
from typing import List
|
|
3
2
|
|
|
4
3
|
from langchain_core.language_models import BaseChatModel
|
|
5
4
|
from langchain_openai import ChatOpenAI
|
|
6
|
-
from pydantic import BaseModel
|
|
5
|
+
from pydantic import BaseModel
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
class SkillConfig(BaseModel):
|
|
10
|
-
id: str
|
|
11
|
-
name: str
|
|
12
|
-
description: str
|
|
13
|
-
tags: List[str]
|
|
9
|
+
id: str
|
|
10
|
+
name: str
|
|
11
|
+
description: str
|
|
12
|
+
tags: List[str]
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
class LLMConfig(BaseModel):
|
|
17
|
-
base_url: str
|
|
18
|
-
model: str
|
|
19
|
-
api_key_env: str
|
|
20
|
-
reasoning_effort: str
|
|
16
|
+
base_url: str
|
|
17
|
+
model: str
|
|
18
|
+
api_key_env: str
|
|
19
|
+
reasoning_effort: str
|
|
20
|
+
system_prompt: str
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class CardConfig(BaseModel):
|
|
24
|
-
name: str
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
skills: List[SkillConfig]
|
|
24
|
+
name: str
|
|
25
|
+
version: str
|
|
26
|
+
default_input_modes: List[str]
|
|
27
|
+
default_output_modes: List[str]
|
|
28
|
+
preferred_transport_protocol: str
|
|
29
|
+
url: str
|
|
30
|
+
description: str
|
|
31
|
+
skills: List[SkillConfig]
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
class AgentItem(BaseModel):
|
|
35
|
-
card: CardConfig
|
|
36
|
-
llm: LLMConfig
|
|
37
|
-
system_prompt: str = Field(description="The system prompt to use for the LLM or a path to a file containing the system prompt")
|
|
38
|
-
|
|
39
|
-
def __init__(self, /, **data: Any) -> None:
|
|
40
|
-
prompt_or_path= data['system_prompt']
|
|
41
|
-
if os.path.exists(prompt_or_path):
|
|
42
|
-
with open(prompt_or_path, "r", encoding="utf-8") as f:
|
|
43
|
-
data['system_prompt'] = f.read()
|
|
44
|
-
|
|
45
|
-
super().__init__(**data)
|
|
35
|
+
card: CardConfig
|
|
36
|
+
llm: LLMConfig
|
|
46
37
|
|
|
47
38
|
|
|
48
39
|
class AgentConfig(BaseModel):
|
|
49
|
-
agent: AgentItem
|
|
40
|
+
agent: AgentItem
|
|
50
41
|
|
|
51
42
|
|
|
52
43
|
|
distributed_a2a/server.py
CHANGED
|
@@ -57,15 +57,14 @@ def load_app(agent_config: dict[str, Any]) -> FastAPI:
|
|
|
57
57
|
))
|
|
58
58
|
|
|
59
59
|
agent_card = AgentCard(
|
|
60
|
-
name=agent_config.agent.
|
|
61
|
-
description=agent_config.agent.
|
|
62
|
-
url=agent_config.agent.
|
|
63
|
-
version=agent_config.agent.
|
|
64
|
-
default_input_modes=agent_config.agent.
|
|
65
|
-
default_output_modes=agent_config.agent.
|
|
60
|
+
name=agent_config.agent.name,
|
|
61
|
+
description=agent_config.agent.description,
|
|
62
|
+
url=agent_config.agent.url,
|
|
63
|
+
version=agent_config.agent.version,
|
|
64
|
+
default_input_modes=agent_config.agent.default_input_modes,
|
|
65
|
+
default_output_modes=agent_config.agent.default_output_modes,
|
|
66
66
|
skills=skills,
|
|
67
|
-
preferred_transport=agent_config.agent.
|
|
68
|
-
capabilities=CAPABILITIES
|
|
67
|
+
preferred_transport=agent_config.agent.preferred_transport_protocol,
|
|
69
68
|
)
|
|
70
69
|
|
|
71
70
|
|
|
@@ -83,5 +82,5 @@ def load_app(agent_config: dict[str, Any]) -> FastAPI:
|
|
|
83
82
|
http_handler=DefaultRequestHandler(
|
|
84
83
|
agent_executor=executor,
|
|
85
84
|
task_store=InMemoryTaskStore() #TODO replace with dynamodb store
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
)
|
|
86
|
+
).build(title=agent_card.name, lifespan=lifespan)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: distributed_a2a
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5rc1
|
|
4
4
|
Summary: A library for building A2A agents with routing capabilities
|
|
5
5
|
Home-page: https://github.com/Barra-Technologies/distributed-a2a
|
|
6
6
|
Author: Fabian Bell
|
|
@@ -23,7 +23,6 @@ Requires-Dist: langchain>=0.1.0
|
|
|
23
23
|
Requires-Dist: langchain-core>=0.1.0
|
|
24
24
|
Requires-Dist: langchain-openai>=0.0.5
|
|
25
25
|
Requires-Dist: langgraph>=0.0.20
|
|
26
|
-
Requires-Dist: langgraph-dynamodb-checkpoint>=0.2.6.4
|
|
27
26
|
Requires-Dist: pydantic>=2.0.0
|
|
28
27
|
Requires-Dist: boto3>=1.28.0
|
|
29
28
|
Requires-Dist: a2a>=0.1.0
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
distributed_a2a/__init__.py,sha256=1q_7gRfBCGe-7sF_9YKzevyS97XQhtuFnZiYHIqaU-0,120
|
|
2
|
+
distributed_a2a/agent.py,sha256=fW3htAZkZucuuowvROO0jcscpUMOsH-5loxBZOf6G4U,2642
|
|
3
|
+
distributed_a2a/client.py,sha256=2974Uw8YUuyBytwxxJJKYsWXCpEaIbGmMUHDraITxJ0,4149
|
|
4
|
+
distributed_a2a/executors.py,sha256=PMBAxeE3-ZY2YNiRbgzdksxrsJb4Q10kHzGjt020TEo,4104
|
|
5
|
+
distributed_a2a/model.py,sha256=uyAfvCuuuHoeWnDa2h7-0OqfRbry6VWdhQBbyr3vpro,994
|
|
6
|
+
distributed_a2a/registry.py,sha256=197eZVR6TW0isOUE0VjWSWs7aCqbWqnBzcV8EVXAxrI,677
|
|
7
|
+
distributed_a2a/server.py,sha256=T6KGK9y5j4oq5ewkAEJgVGe945BVNnmz0Fe4FFBR6n8,2948
|
|
8
|
+
distributed_a2a-0.1.5rc1.dist-info/licenses/LICENSE,sha256=Btzdu2kIoMbdSp6OyCLupB1aRgpTCJ_szMimgEnpkkE,1056
|
|
9
|
+
distributed_a2a-0.1.5rc1.dist-info/METADATA,sha256=uVUJcAP6EE4e1uo1q-jUmmI1OEiPtREhFO1XP8zBViU,3106
|
|
10
|
+
distributed_a2a-0.1.5rc1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
+
distributed_a2a-0.1.5rc1.dist-info/top_level.txt,sha256=23qJ8n5k7796BHDK7a58uuO-X4GV0EgUWcGi8NIn-0k,16
|
|
12
|
+
distributed_a2a-0.1.5rc1.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
distributed_a2a/__init__.py,sha256=1q_7gRfBCGe-7sF_9YKzevyS97XQhtuFnZiYHIqaU-0,120
|
|
2
|
-
distributed_a2a/agent.py,sha256=ZI6sFISU5nELEqzVXbZaf7osqVH095raxjmrFzipoDA,2858
|
|
3
|
-
distributed_a2a/client.py,sha256=2974Uw8YUuyBytwxxJJKYsWXCpEaIbGmMUHDraITxJ0,4149
|
|
4
|
-
distributed_a2a/executors.py,sha256=TNHO3eEIlKWObqBblcx_XiP5KahcfaGK1YuajWmQ5rE,4187
|
|
5
|
-
distributed_a2a/model.py,sha256=pvuoVg8QChYq21us49wZa7Pv-BlIU-mlfN2auVQvqdY,2676
|
|
6
|
-
distributed_a2a/registry.py,sha256=197eZVR6TW0isOUE0VjWSWs7aCqbWqnBzcV8EVXAxrI,677
|
|
7
|
-
distributed_a2a/server.py,sha256=eVccqBos4nMQqe9feyglGlMmUYIGz2t5jmBbMVt-NGE,3085
|
|
8
|
-
distributed_a2a-0.1.5.dist-info/licenses/LICENSE,sha256=Btzdu2kIoMbdSp6OyCLupB1aRgpTCJ_szMimgEnpkkE,1056
|
|
9
|
-
distributed_a2a-0.1.5.dist-info/METADATA,sha256=YKbtMhInCY7o5Z0qRoMKKuQPpc-mwrkpGFH8qXglEag,3157
|
|
10
|
-
distributed_a2a-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
-
distributed_a2a-0.1.5.dist-info/top_level.txt,sha256=23qJ8n5k7796BHDK7a58uuO-X4GV0EgUWcGi8NIn-0k,16
|
|
12
|
-
distributed_a2a-0.1.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|