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.
- recallrai/__init__.py +2 -1
- recallrai/client.py +42 -127
- recallrai/exceptions/__init__.py +28 -0
- recallrai/exceptions/auth.py +24 -0
- recallrai/exceptions/base.py +37 -0
- recallrai/exceptions/network.py +58 -0
- recallrai/exceptions/server.py +82 -0
- recallrai/exceptions/sessions.py +60 -0
- recallrai/exceptions/users.py +61 -0
- recallrai/exceptions/validation.py +24 -0
- recallrai/session.py +157 -47
- recallrai/user.py +93 -12
- recallrai/utils/__init__.py +2 -4
- recallrai/utils/http_client.py +123 -0
- recallrai-0.1.1.dist-info/METADATA +440 -0
- recallrai-0.1.1.dist-info/RECORD +20 -0
- recallrai/utils/exceptions.py +0 -61
- recallrai/utils/http.py +0 -167
- recallrai-0.1.0.dist-info/METADATA +0 -268
- recallrai-0.1.0.dist-info/RECORD +0 -13
- {recallrai-0.1.0.dist-info → recallrai-0.1.1.dist-info}/WHEEL +0 -0
recallrai/__init__.py
CHANGED
recallrai/client.py
CHANGED
|
@@ -7,13 +7,15 @@ Main client class for the RecallrAI SDK.
|
|
|
7
7
|
This module provides the RecallrAI class, which is the primary interface for the SDK.
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
-
import uuid
|
|
11
10
|
from typing import Any, Dict, Optional
|
|
12
|
-
from
|
|
13
|
-
from .utils import HTTPClient, RecallrAIError
|
|
14
|
-
from .models import User as UserModel, UserList, SessionStatus, SessionList
|
|
11
|
+
from .models import User as UserModel, UserList
|
|
15
12
|
from .user import User
|
|
16
|
-
from .
|
|
13
|
+
from .utils import HTTPClient
|
|
14
|
+
from .exceptions import (
|
|
15
|
+
UserAlreadyExistsError,
|
|
16
|
+
UserNotFoundError,
|
|
17
|
+
RecallrAIError,
|
|
18
|
+
)
|
|
17
19
|
from logging import getLogger
|
|
18
20
|
|
|
19
21
|
logger = getLogger(__name__)
|
|
@@ -28,8 +30,8 @@ class RecallrAI:
|
|
|
28
30
|
def __init__(
|
|
29
31
|
self,
|
|
30
32
|
api_key: str,
|
|
31
|
-
project_id:
|
|
32
|
-
base_url:
|
|
33
|
+
project_id: str,
|
|
34
|
+
base_url: str = "https://api.recallrai.com",
|
|
33
35
|
timeout: int = 30,
|
|
34
36
|
):
|
|
35
37
|
"""
|
|
@@ -45,8 +47,8 @@ class RecallrAI:
|
|
|
45
47
|
raise ValueError("API key must start with 'rai_'")
|
|
46
48
|
|
|
47
49
|
self.api_key = api_key
|
|
48
|
-
self.project_id =
|
|
49
|
-
self.base_url =
|
|
50
|
+
self.project_id = project_id
|
|
51
|
+
self.base_url = base_url
|
|
50
52
|
|
|
51
53
|
self.http = HTTPClient(
|
|
52
54
|
api_key=self.api_key,
|
|
@@ -68,11 +70,19 @@ class RecallrAI:
|
|
|
68
70
|
The created user object
|
|
69
71
|
|
|
70
72
|
Raises:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
UserAlreadyExistsError: If a user with the same ID already exists
|
|
74
|
+
AuthenticationError: If the API key or project ID is invalid
|
|
75
|
+
InternalServerError: If the server encounters an error
|
|
76
|
+
NetworkError: If there are network issues
|
|
77
|
+
TimeoutError: If the request times out
|
|
78
|
+
RecallrAIError: For other API-related errors
|
|
73
79
|
"""
|
|
74
80
|
response = self.http.post("/api/v1/users", data={"user_id": user_id, "metadata": metadata or {}})
|
|
75
|
-
|
|
81
|
+
if response.status_code == 409:
|
|
82
|
+
raise UserAlreadyExistsError(user_id=user_id)
|
|
83
|
+
elif response.status_code != 201:
|
|
84
|
+
raise RecallrAIError("Failed to create user", http_status=response.status_code)
|
|
85
|
+
user_data = UserModel.from_api_response(response.json())
|
|
76
86
|
return User(self.http, user_data)
|
|
77
87
|
|
|
78
88
|
def get_user(self, user_id: str) -> User:
|
|
@@ -86,10 +96,19 @@ class RecallrAI:
|
|
|
86
96
|
A User object representing the user
|
|
87
97
|
|
|
88
98
|
Raises:
|
|
89
|
-
|
|
99
|
+
UserNotFoundError: If the user is not found
|
|
100
|
+
AuthenticationError: If the API key or project ID is invalid
|
|
101
|
+
InternalServerError: If the server encounters an error
|
|
102
|
+
NetworkError: If there are network issues
|
|
103
|
+
TimeoutError: If the request times out
|
|
104
|
+
RecallrAIError: For other API-related errors
|
|
90
105
|
"""
|
|
91
106
|
response = self.http.get(f"/api/v1/users/{user_id}")
|
|
92
|
-
|
|
107
|
+
if response.status_code == 404:
|
|
108
|
+
raise UserNotFoundError(user_id=user_id)
|
|
109
|
+
elif response.status_code != 200:
|
|
110
|
+
raise RecallrAIError("Failed to retrieve user", http_status=response.status_code)
|
|
111
|
+
user_data = UserModel.from_api_response(response.json())
|
|
93
112
|
return User(self.http, user_data)
|
|
94
113
|
|
|
95
114
|
def list_users(self, offset: int = 0, limit: int = 10) -> UserList:
|
|
@@ -102,119 +121,15 @@ class RecallrAI:
|
|
|
102
121
|
|
|
103
122
|
Returns:
|
|
104
123
|
List of users with pagination info
|
|
105
|
-
"""
|
|
106
|
-
response = self.http.get("/api/v1/users", params={"offset": offset, "limit": limit})
|
|
107
|
-
return UserList.from_api_response(response)
|
|
108
|
-
|
|
109
|
-
def update_user(
|
|
110
|
-
self,
|
|
111
|
-
user_id: str,
|
|
112
|
-
new_metadata: Optional[Dict[str, Any]] = None,
|
|
113
|
-
new_user_id: Optional[str] = None
|
|
114
|
-
) -> User:
|
|
115
|
-
"""
|
|
116
|
-
Update a user's metadata or ID.
|
|
117
|
-
|
|
118
|
-
Args:
|
|
119
|
-
user_id: Current ID of the user
|
|
120
|
-
new_metadata: New metadata to associate with the user
|
|
121
|
-
new_user_id: New ID for the user
|
|
122
|
-
|
|
123
|
-
Returns:
|
|
124
|
-
The updated user
|
|
125
|
-
|
|
126
|
-
Raises:
|
|
127
|
-
NotFoundError: If the user is not found
|
|
128
|
-
ValidationError: If the new_user_id is invalid
|
|
129
|
-
BadRequestError: If a user with the new_user_id already exists
|
|
130
|
-
"""
|
|
131
|
-
data = {}
|
|
132
|
-
if new_metadata is not None:
|
|
133
|
-
data["new_metadata"] = new_metadata
|
|
134
|
-
if new_user_id is not None:
|
|
135
|
-
data["new_user_id"] = new_user_id
|
|
136
|
-
|
|
137
|
-
response = self.http.put(f"/api/v1/users/{user_id}", data=data)
|
|
138
|
-
user_data = UserModel.from_api_response(response)
|
|
139
|
-
return User(self.http, user_data)
|
|
140
|
-
|
|
141
|
-
def delete_user(self, user_id: str) -> None:
|
|
142
|
-
"""
|
|
143
|
-
Delete a user.
|
|
144
|
-
|
|
145
|
-
Args:
|
|
146
|
-
user_id: ID of the user to delete
|
|
147
|
-
|
|
148
|
-
Raises:
|
|
149
|
-
NotFoundError: If the user is not found
|
|
150
|
-
"""
|
|
151
|
-
self.http.delete(f"/api/v1/users/{user_id}")
|
|
152
|
-
|
|
153
|
-
# Session management
|
|
154
|
-
def create_session(self, user_id: str, auto_process_after_minutes: int = -1) -> Session:
|
|
155
|
-
"""
|
|
156
|
-
Create a new session for a user.
|
|
157
|
-
|
|
158
|
-
Args:
|
|
159
|
-
user_id: ID of the user to create the session for
|
|
160
|
-
auto_process_after_minutes: Minutes to wait before auto-processing (-1 to disable)
|
|
161
|
-
|
|
162
|
-
Returns:
|
|
163
|
-
A Session object to interact with the created session
|
|
164
|
-
|
|
165
|
-
Raises:
|
|
166
|
-
NotFoundError: If the user is not found
|
|
167
|
-
ValidationError: If auto_process_after_minutes is invalid
|
|
168
|
-
"""
|
|
169
|
-
response = self.http.post(
|
|
170
|
-
f"/api/v1/users/{user_id}/sessions",
|
|
171
|
-
data={"auto_process_after_minutes": auto_process_after_minutes},
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
session_id = response["session_id"]
|
|
175
|
-
return Session(self.http, user_id, session_id)
|
|
176
|
-
|
|
177
|
-
def get_session(self, user_id: str, session_id: str) -> Session:
|
|
178
|
-
"""
|
|
179
|
-
Get an existing session.
|
|
180
|
-
|
|
181
|
-
Args:
|
|
182
|
-
user_id: ID of the user who owns the session
|
|
183
|
-
session_id: ID of the session to retrieve
|
|
184
|
-
|
|
185
|
-
Returns:
|
|
186
|
-
A Session object to interact with the session
|
|
187
|
-
|
|
188
|
-
Raises:
|
|
189
|
-
NotFoundError: If the user or session is not found
|
|
190
|
-
"""
|
|
191
|
-
# Ensure the session exists by checking its status
|
|
192
|
-
session = Session(self.http, user_id, session_id)
|
|
193
|
-
status = session.get_status()
|
|
194
|
-
if status == SessionStatus.PROCESSING:
|
|
195
|
-
raise RecallrAIError("Session is already processing. You can't add messages to it. Create a new session instead.")
|
|
196
|
-
elif status == SessionStatus.PROCESSED:
|
|
197
|
-
raise RecallrAIError("Session has already been processed. You can't add messages to it. Create a new session instead.")
|
|
198
124
|
|
|
199
|
-
return session
|
|
200
|
-
|
|
201
|
-
def list_sessions(self, user_id: str, offset: int = 0, limit: int = 10) -> SessionList:
|
|
202
|
-
"""
|
|
203
|
-
List sessions for a user with pagination.
|
|
204
|
-
|
|
205
|
-
Args:
|
|
206
|
-
user_id: ID of the user
|
|
207
|
-
offset: Number of records to skip
|
|
208
|
-
limit: Maximum number of records to return
|
|
209
|
-
|
|
210
|
-
Returns:
|
|
211
|
-
List of sessions with pagination info
|
|
212
|
-
|
|
213
125
|
Raises:
|
|
214
|
-
|
|
126
|
+
AuthenticationError: If the API key or project ID is invalid
|
|
127
|
+
InternalServerError: If the server encounters an error
|
|
128
|
+
NetworkError: If there are network issues
|
|
129
|
+
TimeoutError: If the request times out
|
|
130
|
+
RecallrAIError: For other API-related errors
|
|
215
131
|
"""
|
|
216
|
-
response = self.http.get(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
)
|
|
220
|
-
return SessionList.from_api_response(response)
|
|
132
|
+
response = self.http.get("/api/v1/users", params={"offset": offset, "limit": limit})
|
|
133
|
+
if response.status_code != 200:
|
|
134
|
+
raise RecallrAIError("Failed to list users", http_status=response.status_code)
|
|
135
|
+
return UserList.from_api_response(response.json())
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Exceptions for the RecallrAI SDK.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .auth import AuthenticationError
|
|
6
|
+
from .base import RecallrAIError
|
|
7
|
+
from .network import NetworkError, TimeoutError, ConnectionError
|
|
8
|
+
from .server import ServerError, InternalServerError
|
|
9
|
+
from .sessions import SessionError, SessionNotFoundError, InvalidSessionStateError
|
|
10
|
+
from .users import UserError, UserNotFoundError, UserAlreadyExistsError
|
|
11
|
+
from .validation import ValidationError
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"RecallrAIError",
|
|
15
|
+
"AuthenticationError",
|
|
16
|
+
"NetworkError",
|
|
17
|
+
"TimeoutError",
|
|
18
|
+
"ConnectionError",
|
|
19
|
+
"ServerError",
|
|
20
|
+
"InternalServerError",
|
|
21
|
+
"SessionError",
|
|
22
|
+
"SessionNotFoundError",
|
|
23
|
+
"InvalidSessionStateError",
|
|
24
|
+
"UserError",
|
|
25
|
+
"UserNotFoundError",
|
|
26
|
+
"UserAlreadyExistsError",
|
|
27
|
+
"ValidationError",
|
|
28
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Authentication-related exceptions for the RecallrAI SDK.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
from .base import RecallrAIError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AuthenticationError(RecallrAIError):
|
|
10
|
+
"""
|
|
11
|
+
Raised when there is an authentication issue with the API key.
|
|
12
|
+
|
|
13
|
+
This exception is typically raised when the API key is invalid,
|
|
14
|
+
has been revoked, or doesn't have the necessary permissions.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
message: str = "Invalid API key or authentication failed",
|
|
20
|
+
code: str = "authentication_error",
|
|
21
|
+
http_status: int = 401,
|
|
22
|
+
details: Optional[Dict[str, Any]] = None
|
|
23
|
+
):
|
|
24
|
+
super().__init__(message, code, http_status, details)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Base exception classes for the RecallrAI SDK.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RecallrAIError(Exception):
|
|
9
|
+
"""Base exception for all RecallrAI SDK errors."""
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
message: str,
|
|
14
|
+
code: Optional[str] = None,
|
|
15
|
+
http_status: Optional[int] = None,
|
|
16
|
+
details: Optional[Dict[str, Any]] = None
|
|
17
|
+
):
|
|
18
|
+
"""
|
|
19
|
+
Initialize a RecallrAI error.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
message: A human-readable error message
|
|
23
|
+
code: An optional error code
|
|
24
|
+
http_status: The HTTP status code that triggered this error
|
|
25
|
+
details: Optional additional details about the error
|
|
26
|
+
"""
|
|
27
|
+
self.message = message
|
|
28
|
+
self.code = code
|
|
29
|
+
self.http_status = http_status
|
|
30
|
+
self.details = details or {}
|
|
31
|
+
super().__init__(self.message)
|
|
32
|
+
|
|
33
|
+
def __str__(self) -> str:
|
|
34
|
+
"""Return a string representation of the error."""
|
|
35
|
+
if self.code:
|
|
36
|
+
return f"{self.code}: {self.message}"
|
|
37
|
+
return self.message
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Network-related exceptions for the RecallrAI SDK.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
from .base import RecallrAIError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class NetworkError(RecallrAIError):
|
|
10
|
+
"""
|
|
11
|
+
Base class for network-related exceptions.
|
|
12
|
+
|
|
13
|
+
This exception is raised for errors related to network connectivity
|
|
14
|
+
and communication with the RecallrAI API.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
message: str = "Network error occurred",
|
|
20
|
+
code: str = "network_error",
|
|
21
|
+
http_status: Optional[int] = None,
|
|
22
|
+
details: Optional[Dict[str, Any]] = None
|
|
23
|
+
):
|
|
24
|
+
super().__init__(message, code, http_status, details)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class TimeoutError(NetworkError):
|
|
28
|
+
"""
|
|
29
|
+
Raised when a request times out.
|
|
30
|
+
|
|
31
|
+
This exception is raised when a request to the RecallrAI API
|
|
32
|
+
takes longer than the configured timeout.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
message: str = "Request timed out",
|
|
38
|
+
code: str = "timeout",
|
|
39
|
+
details: Optional[Dict[str, Any]] = None
|
|
40
|
+
):
|
|
41
|
+
super().__init__(message, code, None, details)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ConnectionError(NetworkError):
|
|
45
|
+
"""
|
|
46
|
+
Raised when a connection error occurs.
|
|
47
|
+
|
|
48
|
+
This exception is raised when there's an issue connecting to
|
|
49
|
+
the RecallrAI API, such as DNS resolution issues or network unavailability.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
def __init__(
|
|
53
|
+
self,
|
|
54
|
+
message: str = "Failed to connect to the RecallrAI API",
|
|
55
|
+
code: str = "connection_error",
|
|
56
|
+
details: Optional[Dict[str, Any]] = None
|
|
57
|
+
):
|
|
58
|
+
super().__init__(message, code, None, details)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Server-related exceptions for the RecallrAI SDK.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
from .base import RecallrAIError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ServerError(RecallrAIError):
|
|
10
|
+
"""
|
|
11
|
+
Base class for server-related exceptions.
|
|
12
|
+
"""
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
message: str = "Server error occurred",
|
|
16
|
+
code: str = "server_error",
|
|
17
|
+
http_status: int = 500,
|
|
18
|
+
details: Optional[Dict[str, Any]] = None
|
|
19
|
+
):
|
|
20
|
+
super().__init__(message, code, http_status, details)
|
|
21
|
+
|
|
22
|
+
class InternalServerError(ServerError):
|
|
23
|
+
"""
|
|
24
|
+
Raised when the RecallrAI API encounters an internal server error.
|
|
25
|
+
|
|
26
|
+
This exception is typically raised when the API returns a 5xx error code.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
message: str = "Internal server error",
|
|
32
|
+
code: str = "server_error",
|
|
33
|
+
http_status: int = 500,
|
|
34
|
+
details: Optional[Dict[str, Any]] = None
|
|
35
|
+
):
|
|
36
|
+
super().__init__(message, code, http_status, details)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# class RateLimitError(ServerError):
|
|
40
|
+
# """
|
|
41
|
+
# Raised when the API rate limit has been exceeded.
|
|
42
|
+
#
|
|
43
|
+
# This exception is raised when too many requests are made in a
|
|
44
|
+
# short period of time.
|
|
45
|
+
# """
|
|
46
|
+
|
|
47
|
+
# def __init__(
|
|
48
|
+
# self,
|
|
49
|
+
# message: str = "API rate limit exceeded",
|
|
50
|
+
# code: str = "rate_limit_exceeded",
|
|
51
|
+
# http_status: int = 429,
|
|
52
|
+
# retry_after: Optional[int] = None,
|
|
53
|
+
# details: Optional[Dict[str, Any]] = None
|
|
54
|
+
# ):
|
|
55
|
+
# details = details or {}
|
|
56
|
+
# if retry_after:
|
|
57
|
+
# details["retry_after"] = retry_after
|
|
58
|
+
# super().__init__(message, code, http_status, details)
|
|
59
|
+
# self.retry_after = retry_after
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# class ServiceUnavailableError(ServerError):
|
|
63
|
+
# """
|
|
64
|
+
# Raised when the RecallrAI service is temporarily unavailable.
|
|
65
|
+
#
|
|
66
|
+
# This exception is raised when the API is down for maintenance
|
|
67
|
+
# or experiencing issues.
|
|
68
|
+
# """
|
|
69
|
+
|
|
70
|
+
# def __init__(
|
|
71
|
+
# self,
|
|
72
|
+
# message: str = "Service temporarily unavailable",
|
|
73
|
+
# code: str = "service_unavailable",
|
|
74
|
+
# http_status: int = 503,
|
|
75
|
+
# retry_after: Optional[int] = None,
|
|
76
|
+
# details: Optional[Dict[str, Any]] = None
|
|
77
|
+
# ):
|
|
78
|
+
# details = details or {}
|
|
79
|
+
# if retry_after:
|
|
80
|
+
# details["retry_after"] = retry_after
|
|
81
|
+
# super().__init__(message, code, http_status, details)
|
|
82
|
+
# self.retry_after = retry_after
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Sessions-related exceptions for the RecallrAI SDK.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
from .base import RecallrAIError
|
|
7
|
+
|
|
8
|
+
class SessionError(RecallrAIError):
|
|
9
|
+
"""
|
|
10
|
+
Base class for session-related exceptions.
|
|
11
|
+
|
|
12
|
+
This exception is raised for errors related to session management
|
|
13
|
+
in the RecallrAI API.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
message: str = "Session error occurred",
|
|
19
|
+
code: str = "session_error",
|
|
20
|
+
http_status: Optional[int] = None,
|
|
21
|
+
details: Optional[Dict[str, Any]] = None
|
|
22
|
+
):
|
|
23
|
+
super().__init__(message, code, http_status, details)
|
|
24
|
+
|
|
25
|
+
class InvalidSessionStateError(SessionError):
|
|
26
|
+
"""
|
|
27
|
+
Raised when a session is in an invalid state.
|
|
28
|
+
|
|
29
|
+
This exception is typically raised when trying to perform an action
|
|
30
|
+
on a session that is not in the expected state.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(
|
|
34
|
+
self,
|
|
35
|
+
message: str = "Invalid session state",
|
|
36
|
+
code: str = "invalid_session_state",
|
|
37
|
+
http_status: int = 400,
|
|
38
|
+
details: Optional[Dict[str, Any]] = None
|
|
39
|
+
):
|
|
40
|
+
super().__init__(message, code, http_status, details)
|
|
41
|
+
|
|
42
|
+
class SessionNotFoundError(SessionError):
|
|
43
|
+
"""
|
|
44
|
+
Raised when a session is not found.
|
|
45
|
+
|
|
46
|
+
This exception is typically raised when trying to access or modify
|
|
47
|
+
a session that doesn't exist.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
def __init__(
|
|
51
|
+
self,
|
|
52
|
+
session_id: Optional[str] = None,
|
|
53
|
+
message: Optional[str] = None,
|
|
54
|
+
code: str = "session_not_found",
|
|
55
|
+
http_status: int = 404,
|
|
56
|
+
details: Optional[Dict[str, Any]] = None
|
|
57
|
+
):
|
|
58
|
+
message = message or f"Session{f' {session_id}' if session_id else ''} not found"
|
|
59
|
+
super().__init__(message, code, http_status, details)
|
|
60
|
+
self.session_id = session_id
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Users-related exceptions for the RecallrAI SDK.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
from .base import RecallrAIError
|
|
7
|
+
|
|
8
|
+
class UserError(RecallrAIError):
|
|
9
|
+
"""
|
|
10
|
+
Base class for user-related exceptions.
|
|
11
|
+
|
|
12
|
+
This exception is raised for errors related to user management
|
|
13
|
+
in the RecallrAI API.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
message: str = "User error occurred",
|
|
19
|
+
code: str = "user_error",
|
|
20
|
+
http_status: Optional[int] = None,
|
|
21
|
+
details: Optional[Dict[str, Any]] = None
|
|
22
|
+
):
|
|
23
|
+
super().__init__(message, code, http_status, details)
|
|
24
|
+
|
|
25
|
+
class UserNotFoundError(UserError):
|
|
26
|
+
"""
|
|
27
|
+
Raised when a user is not found.
|
|
28
|
+
|
|
29
|
+
This exception is typically raised when trying to access or modify
|
|
30
|
+
a user that doesn't exist.
|
|
31
|
+
"""
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
user_id: Optional[str] = None,
|
|
35
|
+
message: Optional[str] = None,
|
|
36
|
+
code: str = "user_not_found",
|
|
37
|
+
http_status: int = 404,
|
|
38
|
+
details: Optional[Dict[str, Any]] = None
|
|
39
|
+
):
|
|
40
|
+
message = message or f"User{f' {user_id}' if user_id else ''} not found"
|
|
41
|
+
super().__init__(message, code, http_status, details)
|
|
42
|
+
self.user_id = user_id
|
|
43
|
+
|
|
44
|
+
class UserAlreadyExistsError(UserError):
|
|
45
|
+
"""
|
|
46
|
+
Raised when a user already exists.
|
|
47
|
+
|
|
48
|
+
This exception is typically raised when trying to create a user
|
|
49
|
+
that already exists in the system.
|
|
50
|
+
"""
|
|
51
|
+
def __init__(
|
|
52
|
+
self,
|
|
53
|
+
user_id: Optional[str] = None,
|
|
54
|
+
message: Optional[str] = None,
|
|
55
|
+
code: str = "user_already_exists",
|
|
56
|
+
http_status: int = 409,
|
|
57
|
+
details: Optional[Dict[str, Any]] = None
|
|
58
|
+
):
|
|
59
|
+
message = message or f"User{f' {user_id}' if user_id else ''} already exists"
|
|
60
|
+
super().__init__(message, code, http_status, details)
|
|
61
|
+
self.user_id = user_id
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Validation-related exceptions for the RecallrAI SDK.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional, Union
|
|
6
|
+
from .base import RecallrAIError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ValidationError(RecallrAIError):
|
|
10
|
+
"""
|
|
11
|
+
Raised when request parameters fail validation.
|
|
12
|
+
|
|
13
|
+
This exception is raised when the API rejects a request
|
|
14
|
+
due to invalid or missing parameters.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
message: str = "Validation error",
|
|
20
|
+
code: str = "validation_error",
|
|
21
|
+
http_status: int = 422,
|
|
22
|
+
details: Optional[Dict[str, Any]] = None
|
|
23
|
+
):
|
|
24
|
+
super().__init__(message, code, http_status, details)
|