recallrai 0.1.0__py3-none-any.whl → 0.1.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.

Potentially problematic release.


This version of recallrai might be problematic. Click here for more details.

@@ -0,0 +1,440 @@
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
+
@@ -0,0 +1,20 @@
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,,
@@ -1,61 +0,0 @@
1
- # Path: recallrai/exceptions.py
2
- # Description: Custom exceptions for the RecallrAI SDK
3
-
4
- """
5
- Custom exceptions for the RecallrAI SDK.
6
- """
7
-
8
- from typing import Any, Dict, Optional
9
-
10
-
11
- class RecallrAIError(Exception):
12
- """Base exception for all RecallrAI SDK errors."""
13
-
14
- def __init__(self, message: str, code: Optional[str] = None, details: Optional[Dict[str, Any]] = None):
15
- """
16
- Initialize a RecallrAI error.
17
-
18
- Args:
19
- message: A human-readable error message
20
- code: An optional error code
21
- details: Optional additional details about the error
22
- """
23
- self.message = message
24
- self.code = code
25
- self.details = details or {}
26
- super().__init__(self.message)
27
-
28
-
29
- class AuthenticationError(RecallrAIError):
30
- """Raised when there is an authentication issue with the API key or project ID."""
31
- pass
32
-
33
-
34
- class NotFoundError(RecallrAIError):
35
- """Raised when a requested resource is not found."""
36
- pass
37
-
38
-
39
- class ValidationError(RecallrAIError):
40
- """Raised when the API rejects a request due to validation errors."""
41
- pass
42
-
43
-
44
- class RateLimitError(RecallrAIError):
45
- """Raised when the API rate limit has been exceeded."""
46
- pass
47
-
48
-
49
- class ServerError(RecallrAIError):
50
- """Raised when the API encounters an unexpected server error."""
51
- pass
52
-
53
-
54
- class BadRequestError(RecallrAIError):
55
- """Raised when the API rejects a request due to invalid parameters."""
56
- pass
57
-
58
-
59
- class SessionProcessingError(RecallrAIError):
60
- """Raised when there is an error processing a session."""
61
- pass
recallrai/utils/http.py DELETED
@@ -1,167 +0,0 @@
1
- # Path: recallrai/utils/http.py
2
- # Description: HTTP client utilities for the RecallrAI SDK
3
-
4
- """
5
- HTTP client utilities for making requests to the RecallrAI API.
6
- """
7
-
8
- import json
9
- from typing import Any, Dict, Optional, Tuple, Union
10
-
11
- import httpx
12
-
13
- from .exceptions import (
14
- AuthenticationError,
15
- BadRequestError,
16
- NotFoundError,
17
- RateLimitError,
18
- RecallrAIError,
19
- ServerError,
20
- ValidationError,
21
- )
22
-
23
- ACCEPTED_STATUS_CODES = [
24
- 200, # OK
25
- 201, # Created
26
- 204, # No Content
27
- ]
28
-
29
- class HTTPClient:
30
- """HTTP client for making requests to the RecallrAI API."""
31
-
32
- def __init__(
33
- self,
34
- api_key: str,
35
- project_id: str,
36
- base_url: str,
37
- timeout: int = 30,
38
- ):
39
- """
40
- Initialize the HTTP client.
41
-
42
- Args:
43
- api_key: Your RecallrAI API key
44
- project_id: Your project ID
45
- base_url: The base URL for the RecallrAI API
46
- timeout: Request timeout in seconds
47
- """
48
- self.api_key = api_key
49
- self.project_id = project_id
50
- self.base_url = base_url.rstrip("/")
51
- self.timeout = timeout
52
- self.client = httpx.Client(
53
- timeout=self.timeout,
54
- headers={
55
- "X-Api-Key": self.api_key,
56
- "X-Project-Id": self.project_id,
57
- "Content-Type": "application/json",
58
- "Accept": "application/json",
59
- "User-Agent": "RecallrAI-Python-SDK",
60
- # TODO: "SDK-Version": "0.1.0",
61
- },
62
- )
63
-
64
- def _handle_response(self, response: httpx.Response) -> Dict[str, Any]:
65
- """
66
- Handle the HTTP response and raise appropriate exceptions for errors.
67
-
68
- Args:
69
- response: The HTTP response from the API
70
-
71
- Returns:
72
- The parsed JSON response body
73
-
74
- Raises:
75
- AuthenticationError: When the API key or project ID is invalid
76
- NotFoundError: When the requested resource is not found
77
- ValidationError: When the API rejects the request due to validation errors
78
- RateLimitError: When the API rate limit has been exceeded
79
- ServerError: When the API encounters an unexpected server error
80
- RecallrAIError: For other types of errors
81
- """
82
- if response.status_code == 204:
83
- return {}
84
-
85
- try:
86
- data = response.json() if response.content else {}
87
- except json.JSONDecodeError:
88
- data = {}
89
-
90
- error_detail = data.get("detail", "Unknown error")
91
-
92
- if response.status_code in ACCEPTED_STATUS_CODES:
93
- return data
94
- elif response.status_code == 400:
95
- raise BadRequestError(message=f"Bad request: {error_detail}", details=data)
96
- elif response.status_code == 401:
97
- raise AuthenticationError(message="Invalid API key or project ID", details=data)
98
- elif response.status_code == 404:
99
- raise NotFoundError(message=f"Resource not found: {error_detail}", details=data)
100
- elif response.status_code == 422:
101
- raise ValidationError(message=f"Validation error: {error_detail}", details=data)
102
- elif response.status_code == 429:
103
- raise RateLimitError(message="API rate limit exceeded", details=data)
104
- elif response.status_code >= 500:
105
- raise ServerError(message=f"Server error: {error_detail}", details=data)
106
- else:
107
- raise RecallrAIError(
108
- message=f"Unexpected error: {response.status_code} - {error_detail}",
109
- details=data,
110
- )
111
-
112
- def request(
113
- self,
114
- method: str,
115
- path: str,
116
- params: Optional[Dict[str, Any]] = None,
117
- data: Optional[Dict[str, Any]] = None,
118
- ) -> Dict[str, Any]:
119
- """
120
- Make a request to the RecallrAI API.
121
-
122
- Args:
123
- method: HTTP method (GET, POST, PUT, DELETE)
124
- path: API endpoint path
125
- params: Query parameters
126
- data: Request body data
127
-
128
- Returns:
129
- The parsed JSON response
130
- """
131
- url = f"{self.base_url}{path}"
132
-
133
- # Filter out None values in params and data
134
- if params:
135
- params = {k: v for k, v in params.items() if v is not None}
136
-
137
- if data:
138
- data = {k: v for k, v in data.items() if v is not None}
139
-
140
- try:
141
- response = self.client.request(
142
- method=method,
143
- url=url,
144
- params=params,
145
- json=data,
146
- )
147
- return self._handle_response(response)
148
- except httpx.HTTPError as e:
149
- raise RecallrAIError(f"HTTP error: {str(e)}")
150
- except Exception as e:
151
- raise RecallrAIError(f"Unexpected error: {str(e)}")
152
-
153
- def get(self, path: str, params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
154
- """Make a GET request."""
155
- return self.request("GET", path, params=params)
156
-
157
- def post(self, path: str, data: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
158
- """Make a POST request."""
159
- return self.request("POST", path, data=data)
160
-
161
- def put(self, path: str, data: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
162
- """Make a PUT request."""
163
- return self.request("PUT", path, data=data)
164
-
165
- def delete(self, path: str) -> Dict[str, Any]:
166
- """Make a DELETE request."""
167
- return self.request("DELETE", path)