attp-client 0.0.12__py3-none-any.whl → 0.0.14__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.
attp_client/client.py CHANGED
@@ -21,6 +21,8 @@ from attp_client.utils import envelopizer
21
21
 
22
22
  from attp_core.rs_api import AttpCommand
23
23
 
24
+ from attp_client.utils.trigger_callable import trigger_callable
25
+
24
26
  class ATTPClient:
25
27
 
26
28
  is_connected: bool
@@ -48,7 +50,7 @@ class ATTPClient:
48
50
  self.max_retries = max_retries
49
51
  self.limits = limits or Limits(max_payload_size=50000)
50
52
  self.client = AttpClientSession(self.connection_url, limits=self.limits)
51
- self.logger = logger
53
+ self.logger = logger or getLogger("Ascender Framework")
52
54
 
53
55
  self.route_increment_index = 2
54
56
 
@@ -73,25 +75,26 @@ class ATTPClient:
73
75
  )
74
76
  asyncio.create_task(self.session.start_listener())
75
77
  # Send an authentication frame as soon as connection estabilishes with agenthub
78
+ self.add_event_handler("tools:call", "message", self._tool_callback)
79
+
76
80
  await self.session.authenticate(self.routes)
77
81
  asyncio.create_task(self.session.listen(self.responder))
78
82
 
79
83
  self.router = AttpRouter(self.responder, self.session)
80
84
  self.inference = AttpInferenceAPI(self.router)
81
85
 
82
- self.add_event_handler("tools:call", "message", self._tool_callback)
83
-
84
-
85
-
86
86
  self.disposable = self.responder.pipe(
87
87
  ops.subscribe_on(AsyncIOScheduler(asyncio.get_event_loop())),
88
88
  ).subscribe(
89
- on_next=lambda item: self.logger.debug(f"Received message on route {item.route_id} with correlation ID {item.correlation_id}"),
89
+ on_next=lambda item: trigger_callable(self._handle_incoming, (item,)),
90
90
  on_error=lambda e: self.logger.error(f"Error in responder stream: {e}"),
91
91
  )
92
92
 
93
93
  async def close(self):
94
94
  if self.session:
95
+ if self.disposable:
96
+ self.disposable.dispose()
97
+
95
98
  await self.session.close()
96
99
  self.session = None
97
100
  self.is_connected = False
@@ -34,7 +34,7 @@ class IMessageDTOV2(FixedBaseModel):
34
34
  tool_error_detail: str | None = None
35
35
 
36
36
  specialist_required: MessageEmergencyTypeEnum | None = None
37
- metadata: dict[str, Any] | None = None
37
+ meta: dict[str, str] | None = None # key, value (key is string, value is JSON string, None as value should be 'null' in JSON)
38
38
 
39
39
  def to_wrap(self) -> dict:
40
40
  w = self.model_dump()
@@ -0,0 +1,10 @@
1
+ import asyncio
2
+ from typing import Any, Callable, Mapping
3
+
4
+
5
+ def trigger_callable(
6
+ callable: Callable[..., Any],
7
+ args: tuple[Any] | None = None,
8
+ kwargs: Mapping[str, Any] | None = None
9
+ ):
10
+ asyncio.create_task(callable(*(args or tuple()), **(kwargs or {})))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: attp-client
3
- Version: 0.0.12
3
+ Version: 0.0.14
4
4
  Summary: A python-sdk client for interacting with AgentHub's ATTP protocol (Agent Tool Transport Protocol)
5
5
  License: MIT
6
6
  Author: Ascender Team
@@ -1,6 +1,6 @@
1
1
  attp_client/__init__.py,sha256=25qGMUU_W8juBuW9N6318vWoqALrPQSp3ECHHkNzUcg,2749
2
2
  attp_client/catalog.py,sha256=TLQvNKx3GtEYcyqWCJuvF6soZXeebKn6wfQNcvV4cX0,4921
3
- attp_client/client.py,sha256=CMDj0NMBGDtGGQqz340L2-xafZfpNIxA2zPYdPbkDps,7531
3
+ attp_client/client.py,sha256=UeKyGTmgp9SG2iyGGhSzj4b9nuN8nZhES0pQ6O7XWw0,7643
4
4
  attp_client/consts.py,sha256=6UZyqWddycOp-TKW5yvb0JW2fdfcS-J2xFVVNfuJQbU,18
5
5
  attp_client/errors/attp_exception.py,sha256=HePYyYMknS4t6tMrwU-p9L_LPdj1i7chntrlM53ueK4,347
6
6
  attp_client/errors/correlated_rpc_exception.py,sha256=GivYlF0rC4zxbEt5sMxc1cO-iGxIuiEjTy7knN_iur4,591
@@ -18,7 +18,7 @@ attp_client/interfaces/handshake/ready.py,sha256=0gEqwbvgRHkHb3FIn4YEyJ8LuzzP260
18
18
  attp_client/interfaces/inference/enums/message_data_type.py,sha256=v68IW8DMyb-ezGnyR6T5kPE70FPDZ14AvCP2mI-iLPo,397
19
19
  attp_client/interfaces/inference/enums/message_emergency_type.py,sha256=8s6PONMUdNzrxVLM5aTAicdKSk6BsRFLujVUsm5jopM,149
20
20
  attp_client/interfaces/inference/enums/message_type.py,sha256=joo6t9vLDeupEtfE1II_-oW6Y_c9zSAGe0bl32TqAlA,508
21
- attp_client/interfaces/inference/message.py,sha256=zoKf1yxRsbFqPlsDpO5zVFVgIqDAbc7xkbIcivao1HU,1637
21
+ attp_client/interfaces/inference/message.py,sha256=EARemMZJjGBGYCnYDMTmK01MIxtE83rzMpnZcF0V2wY,1724
22
22
  attp_client/interfaces/inference/tool.py,sha256=Oabb7w0HJtpyO-AcezmojdsJMGuLH4JHXft7h4mlyX8,134
23
23
  attp_client/interfaces/route_mappings.py,sha256=j6hEdkCP5xPpHS16EWmlkdTlnHa7z6e8ukbY-NolKcQ,416
24
24
  attp_client/misc/fixed_basemodel.py,sha256=0MTVmlTrA75Oxv0pVfLdXFTSp5AmBzgiNwvDiLFGF_w,1853
@@ -31,6 +31,7 @@ attp_client/utils/context_awaiter.py,sha256=oCptu5g8mY43j5cr-W4fOe85OCCaqQI9r_Pn
31
31
  attp_client/utils/envelopizer.py,sha256=wnFEnEEDGx8eW-UYlhpTeOTyLLXnjBYw3-BOHWG-Hhk,310
32
32
  attp_client/utils/route_mapper.py,sha256=uJNhKp6ipCSUxoiZS0Liix2lHOgUAnJM0kfgXWAh9RQ,554
33
33
  attp_client/utils/serializer.py,sha256=O1tWYbQS9jC9aus-ISKtliKCgGmOEIb9hxykVrmMKGY,636
34
- attp_client-0.0.12.dist-info/METADATA,sha256=wEjryMsdgzAvxunWhCPOyUyLVAn47Zpf0UCvBFn4YTc,7138
35
- attp_client-0.0.12.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
36
- attp_client-0.0.12.dist-info/RECORD,,
34
+ attp_client/utils/trigger_callable.py,sha256=F5z0JJcSW7UU0Ss4rbCluBM4uhge__27X3p1faMfqmE,271
35
+ attp_client-0.0.14.dist-info/METADATA,sha256=YWkkMsh_i6UzBbX1d7P_RB3hWMMUDJ_f5c8ucGMRIwM,7138
36
+ attp_client-0.0.14.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
37
+ attp_client-0.0.14.dist-info/RECORD,,