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
recallrai/__init__.py
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
# Path: recallrai/__init__.py
|
|
2
|
-
# Description: Package initialization file with SDK version and main class exports
|
|
3
|
-
|
|
4
1
|
"""
|
|
5
|
-
RecallrAI Python SDK
|
|
2
|
+
RecallrAI Python SDK.
|
|
6
3
|
|
|
7
4
|
This package provides a Python interface to interact with the RecallrAI API.
|
|
8
5
|
"""
|
|
@@ -11,7 +8,7 @@ from .client import RecallrAI
|
|
|
11
8
|
from .user import User
|
|
12
9
|
from .session import Session
|
|
13
10
|
|
|
14
|
-
__version__ = "0.
|
|
11
|
+
__version__ = "0.3.0"
|
|
15
12
|
|
|
16
13
|
__all__ = [
|
|
17
14
|
"RecallrAI",
|
recallrai/client.py
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
# Path: recallrai/client.py
|
|
2
|
-
# Description: Main client class for the RecallrAI SDK
|
|
3
|
-
|
|
4
1
|
"""
|
|
5
2
|
Main client class for the RecallrAI SDK.
|
|
6
3
|
|
|
7
4
|
This module provides the RecallrAI class, which is the primary interface for the SDK.
|
|
8
5
|
"""
|
|
9
6
|
|
|
7
|
+
import json
|
|
10
8
|
from typing import Any, Dict, Optional
|
|
11
|
-
from .models import
|
|
9
|
+
from .models import UserModel, UserList
|
|
12
10
|
from .user import User
|
|
13
11
|
from .utils import HTTPClient
|
|
14
12
|
from .exceptions import (
|
|
@@ -38,98 +36,112 @@ class RecallrAI:
|
|
|
38
36
|
Initialize the RecallrAI client.
|
|
39
37
|
|
|
40
38
|
Args:
|
|
41
|
-
api_key: Your RecallrAI API key
|
|
42
|
-
project_id: Your project ID
|
|
43
|
-
base_url: The base URL for the RecallrAI API
|
|
44
|
-
timeout: Request timeout in seconds
|
|
39
|
+
api_key: Your RecallrAI API key.
|
|
40
|
+
project_id: Your project ID.
|
|
41
|
+
base_url: The base URL for the RecallrAI API.
|
|
42
|
+
timeout: Request timeout in seconds.
|
|
45
43
|
"""
|
|
46
44
|
if not api_key.startswith("rai_"):
|
|
47
45
|
raise ValueError("API key must start with 'rai_'")
|
|
48
46
|
|
|
49
|
-
self.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
self.http = HTTPClient(
|
|
54
|
-
api_key=self.api_key,
|
|
55
|
-
project_id=self.project_id,
|
|
56
|
-
base_url=self.base_url,
|
|
47
|
+
self._http = HTTPClient(
|
|
48
|
+
api_key=api_key,
|
|
49
|
+
project_id=project_id,
|
|
50
|
+
base_url=base_url,
|
|
57
51
|
timeout=timeout,
|
|
58
52
|
)
|
|
59
53
|
|
|
60
54
|
# User management
|
|
61
|
-
def create_user(
|
|
55
|
+
def create_user(
|
|
56
|
+
self,
|
|
57
|
+
user_id: str,
|
|
58
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
59
|
+
) -> User:
|
|
62
60
|
"""
|
|
63
61
|
Create a new user.
|
|
64
62
|
|
|
65
63
|
Args:
|
|
66
|
-
user_id: Unique identifier for the user
|
|
67
|
-
metadata: Optional metadata to associate with the user
|
|
64
|
+
user_id: Unique identifier for the user.
|
|
65
|
+
metadata: Optional metadata to associate with the user.
|
|
68
66
|
|
|
69
67
|
Returns:
|
|
70
|
-
The created user object
|
|
68
|
+
The created user object.
|
|
71
69
|
|
|
72
70
|
Raises:
|
|
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
|
|
71
|
+
UserAlreadyExistsError: If a user with the same ID already exists.
|
|
72
|
+
AuthenticationError: If the API key or project ID is invalid.
|
|
73
|
+
InternalServerError: If the server encounters an error.
|
|
74
|
+
NetworkError: If there are network issues.
|
|
75
|
+
TimeoutError: If the request times out.
|
|
76
|
+
RecallrAIError: For other API-related errors.
|
|
79
77
|
"""
|
|
80
|
-
response = self.
|
|
78
|
+
response = self._http.post("/api/v1/users", data={"user_id": user_id, "metadata": metadata or {}})
|
|
81
79
|
if response.status_code == 409:
|
|
82
|
-
|
|
80
|
+
detail = response.json().get("detail", f"User with ID {user_id} already exists")
|
|
81
|
+
raise UserAlreadyExistsError(message=detail, http_status=response.status_code)
|
|
83
82
|
elif response.status_code != 201:
|
|
84
|
-
|
|
83
|
+
detail = response.json().get("detail", "Failed to create user")
|
|
84
|
+
raise RecallrAIError(message=detail, http_status=response.status_code)
|
|
85
85
|
user_data = UserModel.from_api_response(response.json())
|
|
86
|
-
return User(self.
|
|
86
|
+
return User(self._http, user_data)
|
|
87
87
|
|
|
88
88
|
def get_user(self, user_id: str) -> User:
|
|
89
89
|
"""
|
|
90
90
|
Get a user by ID.
|
|
91
91
|
|
|
92
92
|
Args:
|
|
93
|
-
user_id: Unique identifier of the user
|
|
93
|
+
user_id: Unique identifier of the user.
|
|
94
94
|
|
|
95
95
|
Returns:
|
|
96
|
-
A User object representing the user
|
|
96
|
+
A User object representing the user.
|
|
97
97
|
|
|
98
98
|
Raises:
|
|
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
|
|
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.
|
|
105
105
|
"""
|
|
106
|
-
response = self.
|
|
106
|
+
response = self._http.get(f"/api/v1/users/{user_id}")
|
|
107
107
|
if response.status_code == 404:
|
|
108
|
-
|
|
108
|
+
detail = response.json().get("detail", f"User with ID {user_id} not found")
|
|
109
|
+
raise UserNotFoundError(message=detail, http_status=response.status_code)
|
|
109
110
|
elif response.status_code != 200:
|
|
110
|
-
|
|
111
|
+
detail = response.json().get("detail", "Failed to retrieve user")
|
|
112
|
+
raise RecallrAIError(message=detail, http_status=response.status_code)
|
|
111
113
|
user_data = UserModel.from_api_response(response.json())
|
|
112
|
-
return User(self.
|
|
113
|
-
|
|
114
|
-
def list_users(
|
|
114
|
+
return User(self._http, user_data)
|
|
115
|
+
|
|
116
|
+
def list_users(
|
|
117
|
+
self,
|
|
118
|
+
offset: int = 0,
|
|
119
|
+
limit: int = 10,
|
|
120
|
+
metadata_filter: Optional[Dict[str, Any]] = None
|
|
121
|
+
) -> UserList:
|
|
115
122
|
"""
|
|
116
123
|
List users with pagination.
|
|
117
124
|
|
|
118
125
|
Args:
|
|
119
|
-
offset: Number of records to skip
|
|
120
|
-
limit: Maximum number of records to return
|
|
126
|
+
offset: Number of records to skip.
|
|
127
|
+
limit: Maximum number of records to return.
|
|
121
128
|
|
|
122
129
|
Returns:
|
|
123
|
-
List of users with pagination info
|
|
130
|
+
List of users with pagination info.
|
|
124
131
|
|
|
125
132
|
Raises:
|
|
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
|
|
133
|
+
AuthenticationError: If the API key or project ID is invalid.
|
|
134
|
+
InternalServerError: If the server encounters an error.
|
|
135
|
+
NetworkError: If there are network issues.
|
|
136
|
+
TimeoutError: If the request times out.
|
|
137
|
+
RecallrAIError: For other API-related errors.
|
|
131
138
|
"""
|
|
132
|
-
|
|
139
|
+
params: Dict[str, Any] = {"offset": offset, "limit": limit}
|
|
140
|
+
if metadata_filter is not None:
|
|
141
|
+
params["metadata_filter"] = json.dumps(metadata_filter)
|
|
142
|
+
|
|
143
|
+
response = self._http.get("/api/v1/users", params=params)
|
|
133
144
|
if response.status_code != 200:
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
detail = response.json().get("detail", "Failed to list users")
|
|
146
|
+
raise RecallrAIError(message=detail, http_status=response.status_code)
|
|
147
|
+
return UserList.from_api_response(response.json(), self._http)
|
recallrai/exceptions/__init__.py
CHANGED
|
@@ -2,27 +2,39 @@
|
|
|
2
2
|
Exceptions for the RecallrAI SDK.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from .auth import AuthenticationError
|
|
6
5
|
from .base import RecallrAIError
|
|
7
|
-
from .
|
|
8
|
-
from .
|
|
9
|
-
from .
|
|
10
|
-
from .
|
|
6
|
+
from .auth import AuthenticationError
|
|
7
|
+
from .network import TimeoutError, ConnectionError
|
|
8
|
+
from .server import InternalServerError, RateLimitError
|
|
9
|
+
from .sessions import SessionNotFoundError, InvalidSessionStateError
|
|
10
|
+
from .users import UserNotFoundError, UserAlreadyExistsError, InvalidCategoriesError
|
|
11
11
|
from .validation import ValidationError
|
|
12
|
+
from .merge_conflicts import (
|
|
13
|
+
MergeConflictError,
|
|
14
|
+
MergeConflictNotFoundError,
|
|
15
|
+
MergeConflictAlreadyResolvedError,
|
|
16
|
+
MergeConflictInvalidQuestionsError,
|
|
17
|
+
MergeConflictMissingAnswersError,
|
|
18
|
+
MergeConflictInvalidAnswerError,
|
|
19
|
+
)
|
|
12
20
|
|
|
13
21
|
__all__ = [
|
|
14
22
|
"RecallrAIError",
|
|
15
23
|
"AuthenticationError",
|
|
16
|
-
"NetworkError",
|
|
17
24
|
"TimeoutError",
|
|
18
25
|
"ConnectionError",
|
|
19
|
-
"ServerError",
|
|
20
26
|
"InternalServerError",
|
|
21
|
-
"
|
|
27
|
+
"RateLimitError",
|
|
22
28
|
"SessionNotFoundError",
|
|
23
29
|
"InvalidSessionStateError",
|
|
24
|
-
"UserError",
|
|
25
30
|
"UserNotFoundError",
|
|
26
31
|
"UserAlreadyExistsError",
|
|
32
|
+
"InvalidCategoriesError",
|
|
27
33
|
"ValidationError",
|
|
34
|
+
"MergeConflictError",
|
|
35
|
+
"MergeConflictNotFoundError",
|
|
36
|
+
"MergeConflictAlreadyResolvedError",
|
|
37
|
+
"MergeConflictInvalidQuestionsError",
|
|
38
|
+
"MergeConflictMissingAnswersError",
|
|
39
|
+
"MergeConflictInvalidAnswerError",
|
|
28
40
|
]
|
recallrai/exceptions/auth.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Authentication-related exceptions for the RecallrAI SDK.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import Any, Dict, Optional
|
|
6
5
|
from .base import RecallrAIError
|
|
7
6
|
|
|
8
7
|
|
|
@@ -16,9 +15,7 @@ class AuthenticationError(RecallrAIError):
|
|
|
16
15
|
|
|
17
16
|
def __init__(
|
|
18
17
|
self,
|
|
19
|
-
message: str = "Invalid API key or authentication failed",
|
|
20
|
-
code: str = "authentication_error",
|
|
18
|
+
message: str = "Invalid API key or authentication failed.",
|
|
21
19
|
http_status: int = 401,
|
|
22
|
-
details: Optional[Dict[str, Any]] = None
|
|
23
20
|
):
|
|
24
|
-
super().__init__(message,
|
|
21
|
+
super().__init__(message, http_status)
|
recallrai/exceptions/base.py
CHANGED
|
@@ -2,36 +2,25 @@
|
|
|
2
2
|
Base exception classes for the RecallrAI SDK.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import Any, Dict, Optional
|
|
6
|
-
|
|
7
|
-
|
|
8
5
|
class RecallrAIError(Exception):
|
|
9
|
-
"""Base exception for all RecallrAI SDK
|
|
6
|
+
"""Base exception class for all RecallrAI SDK exceptions."""
|
|
10
7
|
|
|
11
8
|
def __init__(
|
|
12
9
|
self,
|
|
13
10
|
message: str,
|
|
14
|
-
|
|
15
|
-
http_status: Optional[int] = None,
|
|
16
|
-
details: Optional[Dict[str, Any]] = None
|
|
11
|
+
http_status: int,
|
|
17
12
|
):
|
|
18
13
|
"""
|
|
19
14
|
Initialize a RecallrAI error.
|
|
20
15
|
|
|
21
16
|
Args:
|
|
22
|
-
message: A human-readable error message
|
|
23
|
-
|
|
24
|
-
http_status: The HTTP status code that triggered this error
|
|
25
|
-
details: Optional additional details about the error
|
|
17
|
+
message: A human-readable error message.
|
|
18
|
+
http_status: The HTTP status code that triggered this error.
|
|
26
19
|
"""
|
|
27
20
|
self.message = message
|
|
28
|
-
self.code = code
|
|
29
21
|
self.http_status = http_status
|
|
30
|
-
self.details = details or {}
|
|
31
22
|
super().__init__(self.message)
|
|
32
23
|
|
|
33
24
|
def __str__(self) -> str:
|
|
34
25
|
"""Return a string representation of the error."""
|
|
35
|
-
|
|
36
|
-
return f"{self.code}: {self.message}"
|
|
37
|
-
return self.message
|
|
26
|
+
return f"{self.message}. HTTP Status: {self.http_status}."
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Merge conflicts-related exceptions for the RecallrAI SDK.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .base import RecallrAIError
|
|
6
|
+
|
|
7
|
+
class MergeConflictError(RecallrAIError):
|
|
8
|
+
"""
|
|
9
|
+
Base class for merge conflict-related exceptions.
|
|
10
|
+
|
|
11
|
+
This exception is raised for errors related to merge conflict management
|
|
12
|
+
in the RecallrAI API.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, message: str, http_status: int):
|
|
16
|
+
super().__init__(message, http_status)
|
|
17
|
+
|
|
18
|
+
class MergeConflictNotFoundError(MergeConflictError):
|
|
19
|
+
"""
|
|
20
|
+
Raised when a merge conflict is not found.
|
|
21
|
+
|
|
22
|
+
This exception is typically raised when trying to access or modify
|
|
23
|
+
a merge conflict that doesn't exist.
|
|
24
|
+
"""
|
|
25
|
+
def __init__(self, message: str, http_status: int):
|
|
26
|
+
super().__init__(message, http_status)
|
|
27
|
+
|
|
28
|
+
class MergeConflictAlreadyResolvedError(MergeConflictError):
|
|
29
|
+
"""
|
|
30
|
+
Raised when trying to resolve a merge conflict that is already resolved.
|
|
31
|
+
|
|
32
|
+
This exception is typically raised when trying to resolve a merge conflict
|
|
33
|
+
that has already been processed.
|
|
34
|
+
"""
|
|
35
|
+
def __init__(self, message: str, http_status: int):
|
|
36
|
+
super().__init__(message, http_status)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class MergeConflictInvalidQuestionsError(MergeConflictError):
|
|
40
|
+
"""
|
|
41
|
+
Raised when trying to resolve a merge conflict with invalid questions.
|
|
42
|
+
|
|
43
|
+
This exception is raised when the provided questions don't match the
|
|
44
|
+
original clarifying questions for the merge conflict.
|
|
45
|
+
"""
|
|
46
|
+
def __init__(self, message: str, http_status: int):
|
|
47
|
+
super().__init__(message, http_status)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class MergeConflictMissingAnswersError(MergeConflictError):
|
|
51
|
+
"""
|
|
52
|
+
Raised when trying to resolve a merge conflict with missing answers.
|
|
53
|
+
|
|
54
|
+
This exception is raised when not all required clarifying questions
|
|
55
|
+
have been answered.
|
|
56
|
+
"""
|
|
57
|
+
def __init__(self, message: str, http_status: int):
|
|
58
|
+
super().__init__(message, http_status)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class MergeConflictInvalidAnswerError(MergeConflictError):
|
|
62
|
+
"""
|
|
63
|
+
Raised when trying to resolve a merge conflict with invalid answer options.
|
|
64
|
+
|
|
65
|
+
This exception is raised when the provided answer is not one of the
|
|
66
|
+
valid options for a question.
|
|
67
|
+
"""
|
|
68
|
+
def __init__(self, message: str, http_status: int):
|
|
69
|
+
super().__init__(message, http_status)
|
recallrai/exceptions/network.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Network-related exceptions for the RecallrAI SDK.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import Any, Dict, Optional
|
|
6
5
|
from .base import RecallrAIError
|
|
7
6
|
|
|
8
7
|
|
|
@@ -14,14 +13,8 @@ class NetworkError(RecallrAIError):
|
|
|
14
13
|
and communication with the RecallrAI API.
|
|
15
14
|
"""
|
|
16
15
|
|
|
17
|
-
def __init__(
|
|
18
|
-
|
|
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)
|
|
16
|
+
def __init__(self, message: str, http_status: int):
|
|
17
|
+
super().__init__(message, http_status)
|
|
25
18
|
|
|
26
19
|
|
|
27
20
|
class TimeoutError(NetworkError):
|
|
@@ -32,13 +25,8 @@ class TimeoutError(NetworkError):
|
|
|
32
25
|
takes longer than the configured timeout.
|
|
33
26
|
"""
|
|
34
27
|
|
|
35
|
-
def __init__(
|
|
36
|
-
|
|
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)
|
|
28
|
+
def __init__(self, message: str, http_status: int):
|
|
29
|
+
super().__init__(message, http_status)
|
|
42
30
|
|
|
43
31
|
|
|
44
32
|
class ConnectionError(NetworkError):
|
|
@@ -49,10 +37,5 @@ class ConnectionError(NetworkError):
|
|
|
49
37
|
the RecallrAI API, such as DNS resolution issues or network unavailability.
|
|
50
38
|
"""
|
|
51
39
|
|
|
52
|
-
def __init__(
|
|
53
|
-
|
|
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)
|
|
40
|
+
def __init__(self, message: str, http_status: int):
|
|
41
|
+
super().__init__(message, http_status)
|
recallrai/exceptions/server.py
CHANGED
|
@@ -2,22 +2,18 @@
|
|
|
2
2
|
Server-related exceptions for the RecallrAI SDK.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import Any, Dict, Optional
|
|
6
5
|
from .base import RecallrAIError
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
class ServerError(RecallrAIError):
|
|
10
9
|
"""
|
|
11
10
|
Base class for server-related exceptions.
|
|
11
|
+
|
|
12
|
+
This exception serves as the base for all exceptions related to
|
|
13
|
+
server-side errors in the RecallrAI API.
|
|
12
14
|
"""
|
|
13
|
-
def __init__(
|
|
14
|
-
|
|
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)
|
|
15
|
+
def __init__(self, message: str, http_status: int):
|
|
16
|
+
super().__init__(message, http_status)
|
|
21
17
|
|
|
22
18
|
class InternalServerError(ServerError):
|
|
23
19
|
"""
|
|
@@ -26,38 +22,19 @@ class InternalServerError(ServerError):
|
|
|
26
22
|
This exception is typically raised when the API returns a 5xx error code.
|
|
27
23
|
"""
|
|
28
24
|
|
|
29
|
-
def __init__(
|
|
30
|
-
|
|
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
|
-
|
|
25
|
+
def __init__(self, message: str, http_status: int):
|
|
26
|
+
super().__init__(message, http_status)
|
|
38
27
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
#
|
|
43
|
-
# This exception is raised when too many requests are made in a
|
|
44
|
-
# short period of time.
|
|
45
|
-
# """
|
|
28
|
+
class RateLimitError(ServerError):
|
|
29
|
+
"""
|
|
30
|
+
Raised when the API rate limit has been exceeded.
|
|
46
31
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
32
|
+
This exception is raised when too many requests are made in a
|
|
33
|
+
short period of time.
|
|
34
|
+
"""
|
|
60
35
|
|
|
36
|
+
def __init__(self, message: str, http_status: int):
|
|
37
|
+
super().__init__(message, http_status)
|
|
61
38
|
|
|
62
39
|
# class ServiceUnavailableError(ServerError):
|
|
63
40
|
# """
|
|
@@ -66,10 +43,10 @@ class InternalServerError(ServerError):
|
|
|
66
43
|
# This exception is raised when the API is down for maintenance
|
|
67
44
|
# or experiencing issues.
|
|
68
45
|
# """
|
|
69
|
-
|
|
46
|
+
#
|
|
70
47
|
# def __init__(
|
|
71
48
|
# self,
|
|
72
|
-
# message: str = "Service temporarily unavailable",
|
|
49
|
+
# message: str = "Service temporarily unavailable.",
|
|
73
50
|
# code: str = "service_unavailable",
|
|
74
51
|
# http_status: int = 503,
|
|
75
52
|
# retry_after: Optional[int] = None,
|
recallrai/exceptions/sessions.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Sessions-related exceptions for the RecallrAI SDK.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import Any, Dict, Optional
|
|
6
5
|
from .base import RecallrAIError
|
|
7
6
|
|
|
8
7
|
class SessionError(RecallrAIError):
|
|
@@ -13,14 +12,8 @@ class SessionError(RecallrAIError):
|
|
|
13
12
|
in the RecallrAI API.
|
|
14
13
|
"""
|
|
15
14
|
|
|
16
|
-
def __init__(
|
|
17
|
-
|
|
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)
|
|
15
|
+
def __init__(self, message: str, http_status: int):
|
|
16
|
+
super().__init__(message, http_status)
|
|
24
17
|
|
|
25
18
|
class InvalidSessionStateError(SessionError):
|
|
26
19
|
"""
|
|
@@ -30,14 +23,8 @@ class InvalidSessionStateError(SessionError):
|
|
|
30
23
|
on a session that is not in the expected state.
|
|
31
24
|
"""
|
|
32
25
|
|
|
33
|
-
def __init__(
|
|
34
|
-
|
|
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)
|
|
26
|
+
def __init__(self, message: str, http_status: int):
|
|
27
|
+
super().__init__(message, http_status)
|
|
41
28
|
|
|
42
29
|
class SessionNotFoundError(SessionError):
|
|
43
30
|
"""
|
|
@@ -47,14 +34,5 @@ class SessionNotFoundError(SessionError):
|
|
|
47
34
|
a session that doesn't exist.
|
|
48
35
|
"""
|
|
49
36
|
|
|
50
|
-
def __init__(
|
|
51
|
-
|
|
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
|
|
37
|
+
def __init__(self, message: str, http_status: int):
|
|
38
|
+
super().__init__(message, http_status)
|
recallrai/exceptions/users.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Users-related exceptions for the RecallrAI SDK.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import Any, Dict, Optional
|
|
6
5
|
from .base import RecallrAIError
|
|
7
6
|
|
|
8
7
|
class UserError(RecallrAIError):
|
|
@@ -13,14 +12,8 @@ class UserError(RecallrAIError):
|
|
|
13
12
|
in the RecallrAI API.
|
|
14
13
|
"""
|
|
15
14
|
|
|
16
|
-
def __init__(
|
|
17
|
-
|
|
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)
|
|
15
|
+
def __init__(self, message: str, http_status: int):
|
|
16
|
+
super().__init__(message, http_status)
|
|
24
17
|
|
|
25
18
|
class UserNotFoundError(UserError):
|
|
26
19
|
"""
|
|
@@ -29,17 +22,8 @@ class UserNotFoundError(UserError):
|
|
|
29
22
|
This exception is typically raised when trying to access or modify
|
|
30
23
|
a user that doesn't exist.
|
|
31
24
|
"""
|
|
32
|
-
def __init__(
|
|
33
|
-
|
|
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
|
|
25
|
+
def __init__(self, message: str, http_status: int):
|
|
26
|
+
super().__init__(message, http_status)
|
|
43
27
|
|
|
44
28
|
class UserAlreadyExistsError(UserError):
|
|
45
29
|
"""
|
|
@@ -48,14 +32,15 @@ class UserAlreadyExistsError(UserError):
|
|
|
48
32
|
This exception is typically raised when trying to create a user
|
|
49
33
|
that already exists in the system.
|
|
50
34
|
"""
|
|
51
|
-
def __init__(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
35
|
+
def __init__(self, message: str, http_status: int):
|
|
36
|
+
super().__init__(message, http_status)
|
|
37
|
+
|
|
38
|
+
class InvalidCategoriesError(UserError):
|
|
39
|
+
"""
|
|
40
|
+
Raised when invalid categories are provided for user memories.
|
|
41
|
+
|
|
42
|
+
This exception is typically raised when trying to filter memories
|
|
43
|
+
by categories that don't exist in the project.
|
|
44
|
+
"""
|
|
45
|
+
def __init__(self, message: str, http_status: int):
|
|
46
|
+
super().__init__(message, http_status)
|