assistant-runtime-sdk 1.0.0__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.
@@ -0,0 +1,235 @@
1
+ # Assistant Runtime SDK - Python SDK for Assistant Runtime
2
+ # Copyright (C) 2025 Paul Clinton
3
+ # AGPL-3.0 License
4
+
5
+ """
6
+ Assistant Runtime SDK - Python SDK for Assistant Runtime.
7
+
8
+ A framework-agnostic Python client for integrating with Assistant Runtime APIs.
9
+ Supports both synchronous (requests) and asynchronous (aiohttp) usage.
10
+
11
+ Quick Start:
12
+ >>> from assistant_runtime_sdk import AssistantRuntimeClient
13
+ >>>
14
+ >>> client = AssistantRuntimeClient(
15
+ ... tenant_id="your-tenant-id",
16
+ ... tenant_secret="your-secret",
17
+ ... ar_url="https://ar.example.com"
18
+ ... )
19
+ >>>
20
+ >>> # List available models
21
+ >>> models = client.list_available_models()
22
+ >>>
23
+ >>> # Stream a chat response
24
+ >>> for event in client.stream_chat("session-1", "Hello!", "user@example.com"):
25
+ ... if event["event"] == "stream_chunk":
26
+ ... print(event["data"].get("content", ""), end="")
27
+
28
+ Async Usage:
29
+ >>> from assistant_runtime_sdk import AsyncAssistantRuntimeClient
30
+ >>> import asyncio
31
+ >>>
32
+ >>> async def main():
33
+ ... async with AsyncAssistantRuntimeClient("tenant-id", "secret") as client:
34
+ ... async for event in client.stream_chat("session-1", "Hi!", "user@example.com"):
35
+ ... print(event)
36
+ >>>
37
+ >>> asyncio.run(main())
38
+
39
+ Standalone Functions:
40
+ >>> from assistant_runtime_sdk import get_terms, register_tenant
41
+ >>>
42
+ >>> # Get current terms (no auth required)
43
+ >>> terms = get_terms("https://ar.example.com")
44
+ >>>
45
+ >>> # Register a new tenant
46
+ >>> result = register_tenant(
47
+ ... ar_url="https://ar.example.com",
48
+ ... site_url="https://mysite.frappe.cloud",
49
+ ... terms_accepted=True,
50
+ ... terms_version="1.0",
51
+ ... accepted_by="admin@example.com"
52
+ ... )
53
+
54
+ """
55
+
56
+ __version__ = "1.0.0"
57
+ __author__ = "Paul Clinton"
58
+ __license__ = "AGPL-3.0"
59
+
60
+ # =============================================================================
61
+ # Core Client Classes
62
+ # =============================================================================
63
+
64
+ from .client import AssistantRuntimeClient, get_terms, register_tenant, get_registration_state
65
+
66
+ # Async client - import lazily to avoid requiring aiohttp
67
+ # Skill providers - import lazily to avoid requiring strands-agents
68
+ def __getattr__(name: str):
69
+ """Lazy import for optional dependencies and backwards compatibility."""
70
+ # New names
71
+ if name == "AsyncAssistantRuntimeClient":
72
+ from .async_client import AsyncAssistantRuntimeClient
73
+ return AsyncAssistantRuntimeClient
74
+ if name == "SkillProvider":
75
+ from .skills import SkillProvider
76
+ return SkillProvider
77
+ if name == "AsyncSkillProvider":
78
+ from .skills import AsyncSkillProvider
79
+ return AsyncSkillProvider
80
+
81
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
82
+
83
+
84
+ # =============================================================================
85
+ # Exceptions
86
+ # =============================================================================
87
+
88
+ from .exceptions import (
89
+ ARError,
90
+ ARAuthenticationError,
91
+ ARRateLimitError,
92
+ ARStreamError,
93
+ ARConfigurationError,
94
+ ARAPIError,
95
+ ARTimeoutError,
96
+ ARConnectionError,
97
+ ARBillingUnavailableError,
98
+ )
99
+
100
+ # =============================================================================
101
+ # Utilities
102
+ # =============================================================================
103
+
104
+ from .auth import generate_signature, verify_signature, get_signature_header
105
+ from .streaming import SSEEventType, parse_sse_line, parse_sse_stream
106
+
107
+ # =============================================================================
108
+ # Type Definitions
109
+ # =============================================================================
110
+
111
+ from .types import (
112
+ # Model types
113
+ ModelInfo,
114
+ AutoModeInfo,
115
+ ModelsResponse,
116
+ # Streaming types
117
+ StreamEvent,
118
+ StreamStartData,
119
+ StreamChunkData,
120
+ StreamCompleteData,
121
+ ModelFallbackData,
122
+ RateLimitedData,
123
+ ToolCallStartData,
124
+ ToolCallResultData,
125
+ ApprovalRequiredData,
126
+ # Conversation types
127
+ ConversationInfo,
128
+ MessageInfo,
129
+ PaginationInfo,
130
+ ConversationsResponse,
131
+ MessagesResponse,
132
+ # User types
133
+ UserInfo,
134
+ MCPServerInfo,
135
+ UserAuthStatus,
136
+ # Billing types
137
+ UsageDashboard,
138
+ UsageHistoryEntry,
139
+ UsageHistoryResponse,
140
+ # Tenant types
141
+ TenantInfo,
142
+ TermsInfo,
143
+ # Prompt types
144
+ PromptArgument,
145
+ PromptInfo,
146
+ PromptsResponse,
147
+ # Document types
148
+ DocumentInfo,
149
+ DocumentDetailInfo,
150
+ DocumentUploadResponse,
151
+ DocumentDeleteResponse,
152
+ DocumentAccessUpdateResponse,
153
+ StorageInfo,
154
+ DocumentsListResponse,
155
+ )
156
+
157
+ # =============================================================================
158
+ # Public API
159
+ # =============================================================================
160
+
161
+ __all__ = [
162
+ # Version
163
+ "__version__",
164
+ # Core clients - new names
165
+ "AssistantRuntimeClient",
166
+ "AsyncAssistantRuntimeClient",
167
+ # Skill providers (for Strands Agent integration)
168
+ "SkillProvider",
169
+ "AsyncSkillProvider",
170
+ # Standalone functions
171
+ "get_terms",
172
+ "register_tenant",
173
+ "get_registration_state",
174
+ # Exceptions - new names
175
+ "ARError",
176
+ "ARAuthenticationError",
177
+ "ARRateLimitError",
178
+ "ARStreamError",
179
+ "ARConfigurationError",
180
+ "ARAPIError",
181
+ "ARTimeoutError",
182
+ "ARConnectionError",
183
+ "ARBillingUnavailableError",
184
+ # Auth utilities
185
+ "generate_signature",
186
+ "verify_signature",
187
+ "get_signature_header",
188
+ # Streaming utilities
189
+ "SSEEventType",
190
+ "parse_sse_line",
191
+ "parse_sse_stream",
192
+ # Types - Models
193
+ "ModelInfo",
194
+ "AutoModeInfo",
195
+ "ModelsResponse",
196
+ # Types - Streaming
197
+ "StreamEvent",
198
+ "StreamStartData",
199
+ "StreamChunkData",
200
+ "StreamCompleteData",
201
+ "ModelFallbackData",
202
+ "RateLimitedData",
203
+ "ToolCallStartData",
204
+ "ToolCallResultData",
205
+ "ApprovalRequiredData",
206
+ # Types - Conversations
207
+ "ConversationInfo",
208
+ "MessageInfo",
209
+ "PaginationInfo",
210
+ "ConversationsResponse",
211
+ "MessagesResponse",
212
+ # Types - Users
213
+ "UserInfo",
214
+ "MCPServerInfo",
215
+ "UserAuthStatus",
216
+ # Types - Billing
217
+ "UsageDashboard",
218
+ "UsageHistoryEntry",
219
+ "UsageHistoryResponse",
220
+ # Types - Tenant
221
+ "TenantInfo",
222
+ "TermsInfo",
223
+ # Types - Prompts
224
+ "PromptArgument",
225
+ "PromptInfo",
226
+ "PromptsResponse",
227
+ # Types - Documents
228
+ "DocumentInfo",
229
+ "DocumentDetailInfo",
230
+ "DocumentUploadResponse",
231
+ "DocumentDeleteResponse",
232
+ "DocumentAccessUpdateResponse",
233
+ "StorageInfo",
234
+ "DocumentsListResponse",
235
+ ]