attp-client 0.0.1__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/catalog.py +59 -0
- attp_client/client.py +119 -0
- attp_client/consts.py +1 -0
- attp_client/errors/attp_exception.py +12 -0
- attp_client/errors/correlated_rpc_exception.py +21 -0
- attp_client/errors/dead_session.py +7 -0
- attp_client/errors/not_found.py +2 -0
- attp_client/errors/serialization_error.py +6 -0
- attp_client/errors/unauthenticated_error.py +2 -0
- attp_client/inference.py +131 -0
- attp_client/interfaces/catalogs/catalog.py +6 -0
- attp_client/interfaces/error.py +6 -0
- attp_client/interfaces/handshake/auth.py +9 -0
- attp_client/interfaces/handshake/hello.py +13 -0
- attp_client/interfaces/handshake/ready.py +11 -0
- attp_client/interfaces/inference/enums/message_data_type.py +14 -0
- attp_client/interfaces/inference/enums/message_emergency_type.py +11 -0
- attp_client/interfaces/inference/enums/message_type.py +18 -0
- attp_client/interfaces/inference/message.py +51 -0
- attp_client/interfaces/inference/tool.py +6 -0
- attp_client/interfaces/route_mappings.py +12 -0
- attp_client/misc/fixed_basemodel.py +63 -0
- attp_client/misc/serializable.py +69 -0
- attp_client/router.py +113 -0
- attp_client/session.py +316 -0
- attp_client/tools.py +59 -0
- attp_client/types/route_mapping.py +14 -0
- attp_client/utils/context_awaiter.py +40 -0
- attp_client/utils/route_mapper.py +18 -0
- attp_client/utils/serializer.py +25 -0
- attp_client-0.0.1.dist-info/METADATA +278 -0
- attp_client-0.0.1.dist-info/RECORD +33 -0
- attp_client-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,278 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: attp-client
|
3
|
+
Version: 0.0.1
|
4
|
+
Summary: A python-sdk client for interacting with AgentHub's ATTP protocol (Agent Tool Transport Protocol)
|
5
|
+
License: MIT
|
6
|
+
Author: Ascender Team
|
7
|
+
Requires-Python: >=3.11,<3.14
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
13
|
+
Requires-Dist: ascender-framework (>=2.0rc7,<3.0)
|
14
|
+
Requires-Dist: attp-core (==0.1.10)
|
15
|
+
Requires-Dist: msgpack (>=1.1.1,<2.0.0)
|
16
|
+
Requires-Dist: pydantic (>=2.11.7,<3.0.0)
|
17
|
+
Description-Content-Type: text/markdown
|
18
|
+
|
19
|
+
# ATTP Client
|
20
|
+
|
21
|
+
A Python SDK client for interacting with AgentHub's ATTP (Agent Tool Transport Protocol).
|
22
|
+
|
23
|
+
## Overview
|
24
|
+
|
25
|
+
The ATTP Client provides a comprehensive Python interface for connecting to and interacting with AgentHub's ATTP protocol. It enables real-time communication with AI agents, tool management, and inference operations through a high-performance async/await interface.
|
26
|
+
|
27
|
+
## Features
|
28
|
+
|
29
|
+
- **Async/Await Support**: Built with modern Python async patterns for optimal performance
|
30
|
+
- **Agent Communication**: Direct communication with AI agents through the ATTP protocol
|
31
|
+
- **Tool Management**: Register, unregister, and manage tools in organized catalogs
|
32
|
+
- **Inference API**: Invoke AI agent inference with configurable parameters
|
33
|
+
- **Real-time Messaging**: Stream responses and handle real-time agent interactions
|
34
|
+
- **Event Handling**: Register custom event handlers for connect/disconnect and custom routes
|
35
|
+
- **Authentication**: Secure token-based authentication with organization support
|
36
|
+
|
37
|
+
## Installation
|
38
|
+
|
39
|
+
```bash
|
40
|
+
pip install attp-client
|
41
|
+
```
|
42
|
+
|
43
|
+
Or with Poetry:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
poetry add attp-client
|
47
|
+
```
|
48
|
+
|
49
|
+
## Quick Start
|
50
|
+
|
51
|
+
### Basic Connection
|
52
|
+
|
53
|
+
```python
|
54
|
+
import asyncio
|
55
|
+
from attp_client.client import ATTPClient
|
56
|
+
|
57
|
+
async def main():
|
58
|
+
# Initialize the client
|
59
|
+
client = ATTPClient(
|
60
|
+
agt_token="your_agent_token_here",
|
61
|
+
organization_id=1,
|
62
|
+
connection_url="attp://localhost:6563" # Optional, defaults to localhost
|
63
|
+
)
|
64
|
+
|
65
|
+
# Connect to AgentHub
|
66
|
+
await client.connect()
|
67
|
+
|
68
|
+
# Your code here...
|
69
|
+
|
70
|
+
# Close the connection
|
71
|
+
await client.close()
|
72
|
+
|
73
|
+
if __name__ == "__main__":
|
74
|
+
asyncio.run(main())
|
75
|
+
```
|
76
|
+
|
77
|
+
### Agent Inference
|
78
|
+
|
79
|
+
```python
|
80
|
+
from attp_client.interfaces.inference.message import IMessageDTOV2
|
81
|
+
from attp_client.interfaces.inference.enums.message_type import MessageTypeEnum
|
82
|
+
from uuid import UUID
|
83
|
+
|
84
|
+
# Invoke inference by agent ID
|
85
|
+
response = await client.inference.invoke_inference(
|
86
|
+
agent_id=17,
|
87
|
+
input_configuration={},
|
88
|
+
messages=[
|
89
|
+
IMessageDTOV2(
|
90
|
+
content="Hello, how can you help me?",
|
91
|
+
message_type=MessageTypeEnum.USER_MESSAGE,
|
92
|
+
chat_id=UUID("your-chat-id-here")
|
93
|
+
)
|
94
|
+
],
|
95
|
+
stream=False,
|
96
|
+
timeout=30
|
97
|
+
)
|
98
|
+
|
99
|
+
print("Agent response:", response)
|
100
|
+
```
|
101
|
+
|
102
|
+
### Tool Management
|
103
|
+
|
104
|
+
```python
|
105
|
+
# Register a tool
|
106
|
+
tool_id = await client.tools.register(
|
107
|
+
catalog_name="my_catalog",
|
108
|
+
name="example_tool",
|
109
|
+
description="An example tool for demonstration",
|
110
|
+
schema_id="tool_schema_v1",
|
111
|
+
return_direct=False,
|
112
|
+
timeout_ms=20000
|
113
|
+
)
|
114
|
+
|
115
|
+
# Access a specific catalog
|
116
|
+
catalog = await client.catalog("my_catalog")
|
117
|
+
|
118
|
+
# Unregister a tool
|
119
|
+
await client.tools.unregister("my_catalog", str(tool_id))
|
120
|
+
```
|
121
|
+
|
122
|
+
### Event Handling
|
123
|
+
|
124
|
+
```python
|
125
|
+
def on_connect():
|
126
|
+
print("Connected to AgentHub!")
|
127
|
+
|
128
|
+
def on_disconnect():
|
129
|
+
print("Disconnected from AgentHub!")
|
130
|
+
|
131
|
+
def handle_custom_event(data):
|
132
|
+
print(f"Received custom event: {data}")
|
133
|
+
|
134
|
+
# Register event handlers
|
135
|
+
client.add_event_handler("", "connect", on_connect)
|
136
|
+
client.add_event_handler("", "disconnect", on_disconnect)
|
137
|
+
client.add_event_handler("custom:pattern", "custom", handle_custom_event)
|
138
|
+
```
|
139
|
+
|
140
|
+
## Configuration
|
141
|
+
|
142
|
+
### Client Parameters
|
143
|
+
|
144
|
+
- `agt_token` (str): Your AgentHub authentication token
|
145
|
+
- `organization_id` (int): Your organization ID
|
146
|
+
- `connection_url` (str, optional): ATTP server URL (default: "attp://localhost:6563")
|
147
|
+
- `max_retries` (int, optional): Maximum connection retry attempts (default: 20)
|
148
|
+
- `limits` (Limits, optional): Connection limits configuration
|
149
|
+
- `logger` (Logger, optional): Custom logger instance
|
150
|
+
|
151
|
+
### Connection Limits
|
152
|
+
|
153
|
+
```python
|
154
|
+
from attp_core.rs_api import Limits
|
155
|
+
|
156
|
+
limits = Limits(max_payload_size=50000)
|
157
|
+
client = ATTPClient(
|
158
|
+
agt_token="...",
|
159
|
+
organization_id=1,
|
160
|
+
limits=limits
|
161
|
+
)
|
162
|
+
```
|
163
|
+
|
164
|
+
## API Reference
|
165
|
+
|
166
|
+
### ATTPClient
|
167
|
+
|
168
|
+
The main client class for ATTP communication.
|
169
|
+
|
170
|
+
#### Methods
|
171
|
+
|
172
|
+
- `connect()`: Establish connection to AgentHub
|
173
|
+
- `close()`: Close the connection
|
174
|
+
- `catalog(catalog_name: str)`: Access a specific tool catalog
|
175
|
+
- `add_event_handler(pattern: str, route_type: RouteType, callback: Callable)`: Register event handlers
|
176
|
+
|
177
|
+
#### Properties
|
178
|
+
|
179
|
+
- `inference`: Access to the inference API
|
180
|
+
- `tools`: Access to the tools manager
|
181
|
+
- `router`: Access to the low-level router
|
182
|
+
|
183
|
+
### AttpInferenceAPI
|
184
|
+
|
185
|
+
Handles AI agent inference operations.
|
186
|
+
|
187
|
+
#### Methods
|
188
|
+
|
189
|
+
- `invoke_inference()`: Invoke inference for a specific agent
|
190
|
+
- `invoke_chat_inference()`: Invoke inference for a chat session
|
191
|
+
|
192
|
+
### ToolsManager
|
193
|
+
|
194
|
+
Manages tool registration and organization.
|
195
|
+
|
196
|
+
#### Methods
|
197
|
+
|
198
|
+
- `register()`: Register a new tool
|
199
|
+
- `unregister()`: Remove tool registration
|
200
|
+
|
201
|
+
## Error Handling
|
202
|
+
|
203
|
+
The client includes comprehensive error handling:
|
204
|
+
|
205
|
+
```python
|
206
|
+
from attp_client.errors import (
|
207
|
+
AttpException,
|
208
|
+
DeadSessionError,
|
209
|
+
NotFoundError,
|
210
|
+
SerializationError,
|
211
|
+
UnauthenticatedError
|
212
|
+
)
|
213
|
+
|
214
|
+
try:
|
215
|
+
await client.connect()
|
216
|
+
except UnauthenticatedError:
|
217
|
+
print("Authentication failed - check your token")
|
218
|
+
except DeadSessionError:
|
219
|
+
print("Session has died - reconnection required")
|
220
|
+
except AttpException as e:
|
221
|
+
print(f"ATTP error: {e}")
|
222
|
+
```
|
223
|
+
|
224
|
+
## Requirements
|
225
|
+
|
226
|
+
- Python 3.11 - 3.13
|
227
|
+
- Dependencies:
|
228
|
+
- `pydantic` (>=2.11.7,<3.0.0)
|
229
|
+
- `attp-core` (==0.1.10)
|
230
|
+
- `msgpack` (>=1.1.1,<2.0.0)
|
231
|
+
- `ascender-framework` (>=2.0rc7,<3.0)
|
232
|
+
|
233
|
+
## Development
|
234
|
+
|
235
|
+
### Setup
|
236
|
+
|
237
|
+
```bash
|
238
|
+
# Clone the repository
|
239
|
+
git clone https://github.com/AscenderTeam/attp-client.git
|
240
|
+
cd attp-client
|
241
|
+
|
242
|
+
# Install dependencies
|
243
|
+
poetry install
|
244
|
+
|
245
|
+
# Run tests
|
246
|
+
python -m pytest tests/
|
247
|
+
```
|
248
|
+
|
249
|
+
### Project Structure
|
250
|
+
|
251
|
+
```
|
252
|
+
src/
|
253
|
+
├── attp_client/ # Main package
|
254
|
+
│ ├── client.py # Main client class
|
255
|
+
│ ├── inference.py # AI inference API
|
256
|
+
│ ├── tools.py # Tool management
|
257
|
+
│ ├── catalog.py # Catalog operations
|
258
|
+
│ ├── router.py # Message routing
|
259
|
+
│ ├── session.py # Session management
|
260
|
+
│ ├── errors/ # Exception classes
|
261
|
+
│ ├── interfaces/ # Protocol interfaces
|
262
|
+
│ ├── misc/ # Utilities
|
263
|
+
│ ├── types/ # Type definitions
|
264
|
+
│ └── utils/ # Helper utilities
|
265
|
+
└── tests/ # Test suite
|
266
|
+
```
|
267
|
+
|
268
|
+
## License
|
269
|
+
|
270
|
+
MIT License - see LICENSE file for details.
|
271
|
+
|
272
|
+
## Contributing
|
273
|
+
|
274
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
275
|
+
|
276
|
+
## Support
|
277
|
+
|
278
|
+
For issues and questions, please use the GitHub Issues page or contact the Ascender Team.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
attp_client/catalog.py,sha256=rStW3wveo09hiQOpq7XGlZtqd7dEjc96yowh1VCN78c,1799
|
2
|
+
attp_client/client.py,sha256=aSjDaH1pHkmPsVZBwIrSIMX8QXDtbDfGpVBXR5KgnF4,3989
|
3
|
+
attp_client/consts.py,sha256=6UZyqWddycOp-TKW5yvb0JW2fdfcS-J2xFVVNfuJQbU,18
|
4
|
+
attp_client/errors/attp_exception.py,sha256=HePYyYMknS4t6tMrwU-p9L_LPdj1i7chntrlM53ueK4,347
|
5
|
+
attp_client/errors/correlated_rpc_exception.py,sha256=GivYlF0rC4zxbEt5sMxc1cO-iGxIuiEjTy7knN_iur4,591
|
6
|
+
attp_client/errors/dead_session.py,sha256=BI-EuTqxVP7j23wcD0GfhteyPsKR2xqUsMNm9SWXxNs,306
|
7
|
+
attp_client/errors/not_found.py,sha256=Y-Y_Mki1hQYihJttvO0ugHFu9-73--1wqwdOomp2IEM,39
|
8
|
+
attp_client/errors/serialization_error.py,sha256=Pa8PRzFJrrikA1Ikj0q-0euvXVUMb_qj-NRIp55SfOk,198
|
9
|
+
attp_client/errors/unauthenticated_error.py,sha256=F0V1FjO0qVLMl6Y120y3AXKZnwb5iDD17c4GEMbL5aI,46
|
10
|
+
attp_client/inference.py,sha256=wZ-iF-O8eWDn_YosW234ClnXFa7Gw7I73eD2ugmXvfU,4626
|
11
|
+
attp_client/interfaces/catalogs/catalog.py,sha256=3PxlRwR3y2tbQVfXAkhDIv07AJPraMfH0c_pyi7Y6z8,146
|
12
|
+
attp_client/interfaces/error.py,sha256=fIrk5XlAhMs6mbYQ5PzgwS0v-LIbtne3OlQue4CjWXs,139
|
13
|
+
attp_client/interfaces/handshake/auth.py,sha256=lCbu4Mz50N7-XC5szQKht6xnw-d8pPQMeBviSPfRB2U,337
|
14
|
+
attp_client/interfaces/handshake/hello.py,sha256=hlwWcvSpRebtnbS3lLBYmBm7AfHE4n6dp0ILgfqMUFU,680
|
15
|
+
attp_client/interfaces/handshake/ready.py,sha256=0gEqwbvgRHkHb3FIn4YEyJ8LuzzP260ZMjRUCs2xFV0,446
|
16
|
+
attp_client/interfaces/inference/enums/message_data_type.py,sha256=v68IW8DMyb-ezGnyR6T5kPE70FPDZ14AvCP2mI-iLPo,397
|
17
|
+
attp_client/interfaces/inference/enums/message_emergency_type.py,sha256=8s6PONMUdNzrxVLM5aTAicdKSk6BsRFLujVUsm5jopM,149
|
18
|
+
attp_client/interfaces/inference/enums/message_type.py,sha256=joo6t9vLDeupEtfE1II_-oW6Y_c9zSAGe0bl32TqAlA,508
|
19
|
+
attp_client/interfaces/inference/message.py,sha256=IDaSVJOXzpjf26U4fQGVRvqPSlj2gKgIy_i4OIG7QAs,1589
|
20
|
+
attp_client/interfaces/inference/tool.py,sha256=Oabb7w0HJtpyO-AcezmojdsJMGuLH4JHXft7h4mlyX8,134
|
21
|
+
attp_client/interfaces/route_mappings.py,sha256=j6hEdkCP5xPpHS16EWmlkdTlnHa7z6e8ukbY-NolKcQ,416
|
22
|
+
attp_client/misc/fixed_basemodel.py,sha256=0MTVmlTrA75Oxv0pVfLdXFTSp5AmBzgiNwvDiLFGF_w,1853
|
23
|
+
attp_client/misc/serializable.py,sha256=tU08TsjiLiafAhU1jKd5BxajlHdEDcdKeEiKPqhMSTI,2102
|
24
|
+
attp_client/router.py,sha256=UDHU2xsvTjgSIzMtV0jkPvOYK9R7GFjKfIrjjBHws-Q,4575
|
25
|
+
attp_client/session.py,sha256=YDrd1KYmwKsZW6Xdkt6UprXZzGz6pFFSkk6O7XS6ZsA,11409
|
26
|
+
attp_client/tools.py,sha256=stKrT8cAIIdIpiE8LhH3YPSGa7OsDux-mTeNsT294ng,1765
|
27
|
+
attp_client/types/route_mapping.py,sha256=Kb9ZX88lqihRZr8IryfH1Vg_YAobW699Yjl6Raz1rdg,375
|
28
|
+
attp_client/utils/context_awaiter.py,sha256=oCptu5g8mY43j5cr-W4fOe85OCCaqQI9r_Pn92NgZSY,1035
|
29
|
+
attp_client/utils/route_mapper.py,sha256=uJNhKp6ipCSUxoiZS0Liix2lHOgUAnJM0kfgXWAh9RQ,554
|
30
|
+
attp_client/utils/serializer.py,sha256=O1tWYbQS9jC9aus-ISKtliKCgGmOEIb9hxykVrmMKGY,636
|
31
|
+
attp_client-0.0.1.dist-info/METADATA,sha256=3b74iG5sWjaUpDqeJwjrjJ-8meMF0YOcWGJpEhOiEOI,7137
|
32
|
+
attp_client-0.0.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
33
|
+
attp_client-0.0.1.dist-info/RECORD,,
|