recallrai 0.1.1__py3-none-any.whl → 0.3.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.
Potentially problematic release.
This version of recallrai might be problematic. Click here for more details.
- recallrai/__init__.py +2 -5
- recallrai/client.py +67 -55
- recallrai/exceptions/__init__.py +21 -9
- recallrai/exceptions/auth.py +2 -5
- recallrai/exceptions/base.py +5 -16
- recallrai/exceptions/merge_conflicts.py +69 -0
- recallrai/exceptions/network.py +6 -23
- recallrai/exceptions/server.py +17 -40
- recallrai/exceptions/sessions.py +6 -28
- recallrai/exceptions/users.py +16 -31
- recallrai/exceptions/validation.py +2 -9
- recallrai/merge_conflict.py +189 -0
- recallrai/models/__init__.py +41 -8
- recallrai/models/merge_conflict.py +151 -0
- recallrai/models/session.py +67 -35
- recallrai/models/user.py +138 -23
- recallrai/session.py +197 -150
- recallrai/user.py +353 -78
- recallrai/utils/__init__.py +3 -2
- recallrai/utils/http_client.py +38 -23
- recallrai-0.3.0.dist-info/METADATA +902 -0
- recallrai-0.3.0.dist-info/RECORD +23 -0
- {recallrai-0.1.1.dist-info → recallrai-0.3.0.dist-info}/WHEEL +1 -1
- recallrai-0.1.1.dist-info/METADATA +0 -440
- recallrai-0.1.1.dist-info/RECORD +0 -20
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
recallrai/__init__.py,sha256=X1aM48GKDS_mx_OSD3P0FeWtNrfYpMfkTN5Sqik7w1g,273
|
|
2
|
+
recallrai/client.py,sha256=VNQ-AgmgQIdV5pOfvU7KptYC34jA_tGW1Kt3XnJoa-M,5230
|
|
3
|
+
recallrai/exceptions/__init__.py,sha256=d1LiuofGiGOP8rmzpvUKinKaa_o1cn2JThGr__Hwysw,1209
|
|
4
|
+
recallrai/exceptions/auth.py,sha256=mnxps1GLljuERxzqBZXg_LZqOYUbTM47GLaW9noiP3w,554
|
|
5
|
+
recallrai/exceptions/base.py,sha256=RMCEPqsR4xbdIXLm8DY3th6MHQTQFfowNOYKLgu4Fbc,716
|
|
6
|
+
recallrai/exceptions/merge_conflicts.py,sha256=_rJ4ug6bmBLp7S08gTQHNTWvS1XNSDKf860SzsVyD3s,2265
|
|
7
|
+
recallrai/exceptions/network.py,sha256=MLvfFhIK2cPvqb-Z0IHGUwCNPpwbeww12YO3p7G9T8c,1081
|
|
8
|
+
recallrai/exceptions/server.py,sha256=E39B6-rNNOqFZ4yVdSExDDbqDEALdTbZ5123kaE1ngw,1765
|
|
9
|
+
recallrai/exceptions/sessions.py,sha256=DJffJUhq4lGda-puzStnvLWJr5jlJ9cbIGhPdSNMzTI,1057
|
|
10
|
+
recallrai/exceptions/users.py,sha256=GPoko9BtcnZ-4G9pbCuKvca7d769c64Npk_CEyMVLhM,1352
|
|
11
|
+
recallrai/exceptions/validation.py,sha256=O54apJf4pUsKXbo3A7I2nXV4J-BEk4txrAUNw8vK15o,415
|
|
12
|
+
recallrai/merge_conflict.py,sha256=cEi2-0rOTKQXu61tt1p2LVItyA7l05TyvRw_mfCNIhI,7682
|
|
13
|
+
recallrai/models/__init__.py,sha256=7M9q2BUDVyzCP7UNFmwo5Jzfni8fXibVPUCpiyQwG2w,1010
|
|
14
|
+
recallrai/models/merge_conflict.py,sha256=H0yG-Tja01-vmBrI7mNXrARrgQVxF-LEE1YsB9voXJY,5337
|
|
15
|
+
recallrai/models/session.py,sha256=xtNLoohWG5pmABf40y0zhU8Bo3guS8S6hbh4jFjI8AA,4782
|
|
16
|
+
recallrai/models/user.py,sha256=8amkmBFAV0w2dkFBdp8Zx8nbuzQX3CkhEdpNIDBrqIY,6289
|
|
17
|
+
recallrai/session.py,sha256=sL3StMzjDg9yf5wNf4gCifueUxUMpb36WGEbrFJJKXs,13422
|
|
18
|
+
recallrai/user.py,sha256=_wCi3-RlNaVgDbwfLCiBFNlISPcVifbazw20iZgITWg,19060
|
|
19
|
+
recallrai/utils/__init__.py,sha256=NWqn-HBC3Ahv_0E00-aHGDrTPN0RN1cXrvIxwvQLtZQ,108
|
|
20
|
+
recallrai/utils/http_client.py,sha256=MLkAp2nMBFngnCHL5z8v4K4Vp_huu-ekOrQYkknQMtU,4500
|
|
21
|
+
recallrai-0.3.0.dist-info/METADATA,sha256=00DN0-4YELkT2Z6PV-Tq06xIcE4lHMDDQ5zLRRgdqx8,30262
|
|
22
|
+
recallrai-0.3.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
23
|
+
recallrai-0.3.0.dist-info/RECORD,,
|
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: recallrai
|
|
3
|
-
Version: 0.1.1
|
|
4
|
-
Summary: Official Python SDK for RecallrAI - Revolutionary contextual memory system that enables AI assistants to form meaningful connections between conversations, just like human memory.
|
|
5
|
-
License: MIT
|
|
6
|
-
Keywords: ai,memory,context,llm,mem0,getzep,zep
|
|
7
|
-
Author: Devasheesh Mishra
|
|
8
|
-
Author-email: devasheeshmishra4@gmail.com
|
|
9
|
-
Requires-Python: >=3.8,<4.0
|
|
10
|
-
Classifier: Intended Audience :: Developers
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
-
Requires-Dist: httpx (>=0.25.0,<0.26.0)
|
|
21
|
-
Requires-Dist: pydantic (>=2.4.0,<3.0.0)
|
|
22
|
-
Project-URL: Homepage, https://recallrai.com
|
|
23
|
-
Project-URL: Repository, https://github.com/recallrai/sdk-python
|
|
24
|
-
Description-Content-Type: text/markdown
|
|
25
|
-
|
|
26
|
-
# RecallrAI Python SDK
|
|
27
|
-
|
|
28
|
-
Official Python SDK for RecallrAI – a revolutionary contextual memory system that enables AI assistants to form meaningful connections between conversations, just like human memory.
|
|
29
|
-
|
|
30
|
-
## Installation
|
|
31
|
-
|
|
32
|
-
Install the SDK via Poetry or pip:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
poetry add recallrai
|
|
36
|
-
# or
|
|
37
|
-
pip install recallrai
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Initialization
|
|
41
|
-
|
|
42
|
-
Create a client instance with your API key and project ID:
|
|
43
|
-
|
|
44
|
-
```python
|
|
45
|
-
from recallrai import RecallrAI
|
|
46
|
-
|
|
47
|
-
api_key = "rai_yourapikey"
|
|
48
|
-
project_id = "project-uuid"
|
|
49
|
-
client = RecallrAI(api_key=api_key, project_id=project_id)
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## User Management
|
|
53
|
-
|
|
54
|
-
### Create a User
|
|
55
|
-
|
|
56
|
-
```python
|
|
57
|
-
from recallrai.exceptions import UserAlreadyExistsError
|
|
58
|
-
try:
|
|
59
|
-
user = client.create_user(user_id="user123", metadata={"name": "John Doe"})
|
|
60
|
-
print(f"Created user: {user.user_id}")
|
|
61
|
-
print(f"User metadata: {user.metadata}")
|
|
62
|
-
print(f"Created at: {user.created_at}")
|
|
63
|
-
except UserAlreadyExistsError as e:
|
|
64
|
-
print(f"Error: {e}")
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Get a User
|
|
68
|
-
|
|
69
|
-
```python
|
|
70
|
-
from recallrai.exceptions import UserNotFoundError
|
|
71
|
-
try:
|
|
72
|
-
user = client.get_user("user123")
|
|
73
|
-
print(f"User metadata: {user.metadata}")
|
|
74
|
-
print(f"Last active: {user.last_active_at}")
|
|
75
|
-
except UserNotFoundError as e:
|
|
76
|
-
print(f"Error: {e}")
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### List Users
|
|
80
|
-
|
|
81
|
-
```python
|
|
82
|
-
user_list = client.list_users(offset=0, limit=10)
|
|
83
|
-
print(f"Total users: {user_list.total}")
|
|
84
|
-
print(f"Has more users: {user_list.has_more}")
|
|
85
|
-
|
|
86
|
-
for user in user_list.users:
|
|
87
|
-
print(f"User ID: {user.user_id}")
|
|
88
|
-
print(f"Metadata: {user.metadata}")
|
|
89
|
-
print(f"Created at: {user.created_at}")
|
|
90
|
-
print(f"Last active: {user.last_active_at}")
|
|
91
|
-
print("---")
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Update a User
|
|
95
|
-
|
|
96
|
-
```python
|
|
97
|
-
from recallrai.exceptions import UserNotFoundError, UserAlreadyExistsError
|
|
98
|
-
try:
|
|
99
|
-
user = client.get_user("user123")
|
|
100
|
-
updated_user = user.update(
|
|
101
|
-
new_metadata={"name": "John Doe", "role": "admin"},
|
|
102
|
-
new_user_id="john_doe"
|
|
103
|
-
)
|
|
104
|
-
print(f"Updated user ID: {updated_user.user_id}")
|
|
105
|
-
print(f"Updated metadata: {updated_user.metadata}")
|
|
106
|
-
except UserNotFoundError as e:
|
|
107
|
-
print(f"Error: {e}")
|
|
108
|
-
except UserAlreadyExistsError as e:
|
|
109
|
-
print(f"Error: {e}")
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Delete a User
|
|
113
|
-
|
|
114
|
-
```python
|
|
115
|
-
from recallrai.exceptions import UserNotFoundError
|
|
116
|
-
try:
|
|
117
|
-
user = client.get_user("john_doe")
|
|
118
|
-
user.delete()
|
|
119
|
-
print("User deleted successfully")
|
|
120
|
-
except UserNotFoundError as e:
|
|
121
|
-
print(f"Error: {e}")
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## Session Management
|
|
125
|
-
|
|
126
|
-
### Create a Session
|
|
127
|
-
|
|
128
|
-
```python
|
|
129
|
-
from recallrai.exceptions import UserNotFoundError
|
|
130
|
-
from recallrai.session import Session
|
|
131
|
-
|
|
132
|
-
try:
|
|
133
|
-
# First, get the user
|
|
134
|
-
user = client.get_user("user123")
|
|
135
|
-
|
|
136
|
-
# Create a session for the user; auto_process_after_minutes set to -1 disables auto-processing
|
|
137
|
-
session: Session = user.create_session(auto_process_after_minutes=5)
|
|
138
|
-
print("Created session id:", session.session_id)
|
|
139
|
-
except UserNotFoundError as e:
|
|
140
|
-
print(f"Error: {e}")
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Get an Existing Session
|
|
144
|
-
|
|
145
|
-
```python
|
|
146
|
-
from recallrai.exceptions import UserNotFoundError, SessionNotFoundError
|
|
147
|
-
|
|
148
|
-
try:
|
|
149
|
-
# First, get the user
|
|
150
|
-
user = client.get_user("user123")
|
|
151
|
-
|
|
152
|
-
# Retrieve an existing session by its ID
|
|
153
|
-
session = user.get_session(session_id="session-uuid")
|
|
154
|
-
print("Session status:", session.get_status())
|
|
155
|
-
except UserNotFoundError as e:
|
|
156
|
-
print(f"Error: {e}")
|
|
157
|
-
except SessionNotFoundError as e:
|
|
158
|
-
print(f"Error: {e}")
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### List Sessions
|
|
162
|
-
|
|
163
|
-
```python
|
|
164
|
-
from recallrai.exceptions import UserNotFoundError
|
|
165
|
-
|
|
166
|
-
try:
|
|
167
|
-
# First, get the user
|
|
168
|
-
user = client.get_user("user123")
|
|
169
|
-
|
|
170
|
-
# List sessions for this user
|
|
171
|
-
session_list = user.list_sessions(offset=0, limit=10)
|
|
172
|
-
for session in session_list.sessions:
|
|
173
|
-
print(session.session_id, session.status)
|
|
174
|
-
except UserNotFoundError as e:
|
|
175
|
-
print(f"Error: {e}")
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Session – Adding Messages
|
|
179
|
-
|
|
180
|
-
```python
|
|
181
|
-
from recallrai.exceptions import UserNotFoundError, SessionNotFoundError, InvalidSessionStateError
|
|
182
|
-
|
|
183
|
-
try:
|
|
184
|
-
# Add a user message
|
|
185
|
-
session.add_user_message("Hello! How are you?")
|
|
186
|
-
|
|
187
|
-
# Add an assistant message
|
|
188
|
-
session.add_assistant_message("I'm an assistant. How can I help you?")
|
|
189
|
-
except UserNotFoundError as e:
|
|
190
|
-
print(f"Error: {e}")
|
|
191
|
-
except SessionNotFoundError as e:
|
|
192
|
-
print(f"Error: {e}")
|
|
193
|
-
except InvalidSessionStateError as e:
|
|
194
|
-
print(f"Error: {e}")
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
### Session – Retrieving Context
|
|
198
|
-
|
|
199
|
-
```python
|
|
200
|
-
from recallrai.exceptions import UserNotFoundError, SessionNotFoundError
|
|
201
|
-
|
|
202
|
-
try:
|
|
203
|
-
context = session.get_context()
|
|
204
|
-
print("Memory used:", context.memory_used)
|
|
205
|
-
print("Context:", context.context)
|
|
206
|
-
except UserNotFoundError as e:
|
|
207
|
-
print(f"Error: {e}")
|
|
208
|
-
except SessionNotFoundError as e:
|
|
209
|
-
print(f"Error: {e}")
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### Session – Process Session
|
|
213
|
-
|
|
214
|
-
```python
|
|
215
|
-
from recallrai.exceptions import UserNotFoundError, SessionNotFoundError, InvalidSessionStateError
|
|
216
|
-
|
|
217
|
-
try:
|
|
218
|
-
session.process()
|
|
219
|
-
except UserNotFoundError as e:
|
|
220
|
-
print(f"Error: {e}")
|
|
221
|
-
except SessionNotFoundError as e:
|
|
222
|
-
print(f"Error: {e}")
|
|
223
|
-
except InvalidSessionStateError as e:
|
|
224
|
-
print(f"Error: {e}")
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Session – Get Status and Messages
|
|
228
|
-
|
|
229
|
-
```python
|
|
230
|
-
from recallrai.exceptions import UserNotFoundError, SessionNotFoundError
|
|
231
|
-
from recallrai.models import SessionStatus
|
|
232
|
-
|
|
233
|
-
try:
|
|
234
|
-
status = session.get_status()
|
|
235
|
-
print("Session status:", status)
|
|
236
|
-
|
|
237
|
-
# Check if the session is in a specific state
|
|
238
|
-
if status == SessionStatus.PROCESSED:
|
|
239
|
-
print("Session has been processed")
|
|
240
|
-
|
|
241
|
-
messages = session.get_messages()
|
|
242
|
-
for message in messages:
|
|
243
|
-
print(f"{message.role}: {message.content} at {message.timestamp}")
|
|
244
|
-
except UserNotFoundError as e:
|
|
245
|
-
print(f"Error: {e}")
|
|
246
|
-
except SessionNotFoundError as e:
|
|
247
|
-
print(f"Error: {e}")
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
## Example Usage with LLMs
|
|
251
|
-
|
|
252
|
-
```python
|
|
253
|
-
import openai
|
|
254
|
-
from recallrai import RecallrAI
|
|
255
|
-
from recallrai.exceptions import UserNotFoundError
|
|
256
|
-
|
|
257
|
-
# Initialize RecallrAI and OpenAI clients
|
|
258
|
-
rai_client = RecallrAI(
|
|
259
|
-
api_key="rai_yourapikey",
|
|
260
|
-
project_id="your-project-uuid"
|
|
261
|
-
)
|
|
262
|
-
oai_client = openai.OpenAI(api_key="your-openai-api-key")
|
|
263
|
-
|
|
264
|
-
def chat_with_memory(user_id, session_id=None):
|
|
265
|
-
# Get or create user
|
|
266
|
-
try:
|
|
267
|
-
user = rai_client.get_user(user_id)
|
|
268
|
-
except UserNotFoundError:
|
|
269
|
-
user = rai_client.create_user(user_id)
|
|
270
|
-
|
|
271
|
-
# Create a new session or get an existing one
|
|
272
|
-
if session_id:
|
|
273
|
-
session = user.get_session(session_id=session_id)
|
|
274
|
-
else:
|
|
275
|
-
session = user.create_session(auto_process_after_minutes=30)
|
|
276
|
-
print(f"Created new session: {session.session_id}")
|
|
277
|
-
|
|
278
|
-
print("Chat session started. Type 'exit' to end the conversation.")
|
|
279
|
-
|
|
280
|
-
while True:
|
|
281
|
-
# Get user input
|
|
282
|
-
user_message = input("You: ")
|
|
283
|
-
if user_message.lower() == 'exit':
|
|
284
|
-
break
|
|
285
|
-
|
|
286
|
-
# Add the user message to RecallrAI
|
|
287
|
-
session.add_user_message(user_message)
|
|
288
|
-
|
|
289
|
-
# Get context from RecallrAI after adding the user message
|
|
290
|
-
context = session.get_context()
|
|
291
|
-
|
|
292
|
-
# Create a system prompt that includes the context
|
|
293
|
-
system_prompt = f"""You are a helpful assistant with memory of previous conversations.
|
|
294
|
-
|
|
295
|
-
MEMORIES ABOUT THE USER:
|
|
296
|
-
{context.context}
|
|
297
|
-
|
|
298
|
-
You can use the above memories to provide better responses to the user.
|
|
299
|
-
Don't mention that you have access to memories unless you are explicitly asked."""
|
|
300
|
-
|
|
301
|
-
# Get previous messages
|
|
302
|
-
previous_messages = session.get_messages()
|
|
303
|
-
previous_messages = [{"role": message.role, "content": message.content} for message in previous_messages]
|
|
304
|
-
|
|
305
|
-
# Call the LLM with the system prompt and conversation history
|
|
306
|
-
response = oai_client.chat.completions.create(
|
|
307
|
-
model="gpt-4o-mini",
|
|
308
|
-
messages=[
|
|
309
|
-
{"role": "system", "content": system_prompt},
|
|
310
|
-
**previous_messages,
|
|
311
|
-
],
|
|
312
|
-
temperature=0.7
|
|
313
|
-
)
|
|
314
|
-
|
|
315
|
-
assistant_message = response.choices[0].message.content
|
|
316
|
-
|
|
317
|
-
# Print the assistant's response
|
|
318
|
-
print(f"Assistant: {assistant_message}")
|
|
319
|
-
|
|
320
|
-
# Add the assistant's response to RecallrAI
|
|
321
|
-
session.add_assistant_message(assistant_message)
|
|
322
|
-
|
|
323
|
-
# Process the session at the end of the conversation
|
|
324
|
-
print("Processing session to update memory...")
|
|
325
|
-
session.process()
|
|
326
|
-
print(f"Session ended. Session ID: {session.session_id}")
|
|
327
|
-
return session.session_id
|
|
328
|
-
|
|
329
|
-
# Example usage
|
|
330
|
-
if __name__ == "__main__":
|
|
331
|
-
user_id = "user123"
|
|
332
|
-
# To continue a previous session, uncomment below and provide the session ID
|
|
333
|
-
# previous_session_id = "previously-saved-session-uuid"
|
|
334
|
-
# session_id = chat_with_memory(user_id, previous_session_id)
|
|
335
|
-
|
|
336
|
-
# Start a new session
|
|
337
|
-
session_id = chat_with_memory(user_id)
|
|
338
|
-
print(f"To continue this conversation later, use session ID: {session_id}")
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
## Exception Handling
|
|
342
|
-
|
|
343
|
-
The RecallrAI SDK implements a comprehensive exception hierarchy to help you handle different error scenarios gracefully:
|
|
344
|
-
|
|
345
|
-
### Base Exception
|
|
346
|
-
|
|
347
|
-
- **RecallrAIError**: The base exception for all SDK-specific errors. All other exceptions inherit from this.
|
|
348
|
-
|
|
349
|
-
### Authentication Errors
|
|
350
|
-
|
|
351
|
-
- **AuthenticationError**: Raised when there's an issue with your API key or project ID authentication.
|
|
352
|
-
|
|
353
|
-
### Network-Related Errors
|
|
354
|
-
|
|
355
|
-
- **NetworkError**: Base exception for all network-related issues.
|
|
356
|
-
- **TimeoutError**: Occurs when a request takes too long to complete.
|
|
357
|
-
- **ConnectionError**: Happens when the SDK cannot establish a connection to the RecallrAI API.
|
|
358
|
-
|
|
359
|
-
### Server Errors
|
|
360
|
-
|
|
361
|
-
- **ServerError**: Base class for server-side errors.
|
|
362
|
-
- **InternalServerError**: Raised when the RecallrAI API returns a 5xx error code.
|
|
363
|
-
|
|
364
|
-
### User-Related Errors
|
|
365
|
-
|
|
366
|
-
- **UserError**: Base for all user-related exceptions.
|
|
367
|
-
- **UserNotFoundError**: Raised when attempting to access a user that doesn't exist.
|
|
368
|
-
- **UserAlreadyExistsError**: Occurs when creating a user with an ID that already exists.
|
|
369
|
-
|
|
370
|
-
### Session-Related Errors
|
|
371
|
-
|
|
372
|
-
- **SessionError**: Base for all session-related exceptions.
|
|
373
|
-
- **SessionNotFoundError**: Raised when attempting to access a non-existent session.
|
|
374
|
-
- **InvalidSessionStateError**: Occurs when performing an operation that's not valid for the current session state (e.g., adding a message to a processed session).
|
|
375
|
-
|
|
376
|
-
### Input Validation Errors
|
|
377
|
-
|
|
378
|
-
- **ValidationError**: Raised when provided data doesn't meet the required format or constraints.
|
|
379
|
-
|
|
380
|
-
### Importing Exceptions
|
|
381
|
-
|
|
382
|
-
You can import exceptions directly from the `recallrai.exceptions` module:
|
|
383
|
-
|
|
384
|
-
```python
|
|
385
|
-
# Import specific exceptions
|
|
386
|
-
from recallrai.exceptions import UserNotFoundError, SessionNotFoundError
|
|
387
|
-
|
|
388
|
-
# Import all exceptions
|
|
389
|
-
from recallrai.exceptions import (
|
|
390
|
-
RecallrAIError,
|
|
391
|
-
AuthenticationError,
|
|
392
|
-
NetworkError,
|
|
393
|
-
TimeoutError,
|
|
394
|
-
ConnectionError,
|
|
395
|
-
ServerError,
|
|
396
|
-
InternalServerError,
|
|
397
|
-
SessionError,
|
|
398
|
-
SessionNotFoundError,
|
|
399
|
-
InvalidSessionStateError,
|
|
400
|
-
UserError,
|
|
401
|
-
UserNotFoundError,
|
|
402
|
-
UserAlreadyExistsError,
|
|
403
|
-
ValidationError,
|
|
404
|
-
)
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
### Best Practices for Error Handling
|
|
408
|
-
|
|
409
|
-
When implementing error handling with the RecallrAI SDK, consider these best practices:
|
|
410
|
-
|
|
411
|
-
1. **Handle specific exceptions first**: Catch more specific exceptions before general ones.
|
|
412
|
-
|
|
413
|
-
```python
|
|
414
|
-
try:
|
|
415
|
-
# SDK operation
|
|
416
|
-
except UserNotFoundError:
|
|
417
|
-
# Specific handling
|
|
418
|
-
except RecallrAIError:
|
|
419
|
-
# General fallback
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
2. **Implement retry logic for transient errors**: Network and timeout errors might be temporary.
|
|
423
|
-
|
|
424
|
-
3. **Log detailed error information**: Exceptions contain useful information for debugging.
|
|
425
|
-
|
|
426
|
-
4. **Handle common user flows**: For example, check if a user exists before operations, or create them if they don't:
|
|
427
|
-
|
|
428
|
-
```python
|
|
429
|
-
try:
|
|
430
|
-
user = client.get_user(user_id)
|
|
431
|
-
except UserNotFoundError:
|
|
432
|
-
user = client.create_user(user_id)
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
For more detailed information on specific exceptions, refer to the API documentation.
|
|
436
|
-
|
|
437
|
-
## Conclusion
|
|
438
|
-
|
|
439
|
-
This README outlines the basic usage of the RecallrAI SDK functions for user and session management. For additional documentation and advanced usage, please see the [official documentation](https://recallrai.com) or the source code repository on [GitHub](https://github.com/recallrai/sdk-python).
|
|
440
|
-
|
recallrai-0.1.1.dist-info/RECORD
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
recallrai/__init__.py,sha256=i9HGT5lijm1r9n0iDEHacTYYT1Haq8tu_H0gfsp_-FM,386
|
|
2
|
-
recallrai/client.py,sha256=E68i0jz2uXG50gYZgiM30bt9EQqVvEuw1mTpqxUpwLU,4667
|
|
3
|
-
recallrai/exceptions/__init__.py,sha256=uE-7ywJ1dIJPdUTJisVRXwMzgv6AMgTEpRfDe_d9-1c,782
|
|
4
|
-
recallrai/exceptions/auth.py,sha256=dLabhdTmCBtpp0Ghv3iIw6f3xQn2XXjKCFm1WsiIqXc,700
|
|
5
|
-
recallrai/exceptions/base.py,sha256=0JCs0DoXpMD0XXjrmRR0CXBGxanYpIqBYMbH4d1fndk,1049
|
|
6
|
-
recallrai/exceptions/network.py,sha256=QriByZFgXPEeYfpl_ozxTtzNwHfHtUlPSVb2pAymCx0,1562
|
|
7
|
-
recallrai/exceptions/server.py,sha256=jLINK_3CoOwqKyzKtGB5DwxyZj5S8U2z6zYCZePWqbk,2416
|
|
8
|
-
recallrai/exceptions/sessions.py,sha256=EwcdzxpDxDjUZVu-etgnayWFq2ADmybKfEQuweLw1VE,1777
|
|
9
|
-
recallrai/exceptions/users.py,sha256=kpIhgt92cmW9AOazkD4hgvF8PPq2aYRridtO5pyto8M,1835
|
|
10
|
-
recallrai/exceptions/validation.py,sha256=H0Nnv_RDeah3KzLhB13Ozu0q2cFMJIO-kfl3PWnCpyc,625
|
|
11
|
-
recallrai/models/__init__.py,sha256=2wwbyVAY4IgBn1a7YcbA4i1_pXJpYPYuQo80N8PVTlI,361
|
|
12
|
-
recallrai/models/session.py,sha256=Okn2tMmnl0UPL9q-Bl4cBaUcgs_U_nnvmKj3CHWavGY,3701
|
|
13
|
-
recallrai/models/user.py,sha256=yu7HzceZ-U2Hp6lbRjA31SQsyfD3dmuBoQ9dVGvfZ14,2190
|
|
14
|
-
recallrai/session.py,sha256=Hsj80eyXyj25V-iW3feOIPyQqk5R0JGOcbahqNy-IUM,11053
|
|
15
|
-
recallrai/user.py,sha256=Au3IYTxgyCv35zKrI2MRMMNXWFwBArUCu8W_pN9U9Tc,7714
|
|
16
|
-
recallrai/utils/__init__.py,sha256=buNqocqVT4o62oOOlAE8YOlzUAhbQbbDC3Y2FxIgVAc,157
|
|
17
|
-
recallrai/utils/http_client.py,sha256=QFp9syfIANbNjaVXOiZhj0koX4yGlR5bNxG8AihYvn4,3960
|
|
18
|
-
recallrai-0.1.1.dist-info/METADATA,sha256=6vq_LjhduhyZlMSDxvVkz5GfFctTbhU_R32cHcYMWVM,13265
|
|
19
|
-
recallrai-0.1.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
20
|
-
recallrai-0.1.1.dist-info/RECORD,,
|