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
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: recallrai
|
|
3
|
-
Version: 0.1.0
|
|
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.user import User
|
|
58
|
-
|
|
59
|
-
user_id = "user123"
|
|
60
|
-
metadata = {"key": "value"}
|
|
61
|
-
user = client.create_user(user_id=user_id, metadata=metadata)
|
|
62
|
-
print("Created user:", user.user_id)
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Get a User
|
|
66
|
-
|
|
67
|
-
```python
|
|
68
|
-
user = client.get_user("user123")
|
|
69
|
-
print("User metadata:", user.metadata)
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### List Users
|
|
73
|
-
|
|
74
|
-
```python
|
|
75
|
-
user_list = client.list_users(offset=0, limit=10)
|
|
76
|
-
for user in user_list.users:
|
|
77
|
-
print(user.user_id, user.metadata)
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### Update a User
|
|
81
|
-
|
|
82
|
-
```python
|
|
83
|
-
# Update the user's metadata and/or change the user ID
|
|
84
|
-
updated_user = client.update_user(user_id="user123", new_metadata={"role": "user"}, new_user_id="user1234")
|
|
85
|
-
print("Updated user id:", updated_user.user_id)
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Delete a User
|
|
89
|
-
|
|
90
|
-
```python
|
|
91
|
-
client.delete_user("user1234")
|
|
92
|
-
print("User deleted.")
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Session Management
|
|
96
|
-
|
|
97
|
-
### Create a Session
|
|
98
|
-
|
|
99
|
-
```python
|
|
100
|
-
from recallrai.session import Session
|
|
101
|
-
|
|
102
|
-
# Create a session for a user; auto_process_after_minutes set to -1 disables auto-processing.
|
|
103
|
-
session = client.create_session(user_id="user123", auto_process_after_minutes=5)
|
|
104
|
-
print("Created session id:", session.session_id)
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Get an Existing Session
|
|
108
|
-
|
|
109
|
-
```python
|
|
110
|
-
# Retrieve an existing session by its ID
|
|
111
|
-
session = client.get_session(user_id="user123", session_id="session-uuid")
|
|
112
|
-
print("Session status:", session.get_status())
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### List Sessions
|
|
116
|
-
|
|
117
|
-
```python
|
|
118
|
-
session_list = client.list_sessions(user_id="user123", offset=0, limit=10)
|
|
119
|
-
for session in session_list.sessions:
|
|
120
|
-
print(session.session_id, session.status)
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Session – Adding Messages
|
|
124
|
-
|
|
125
|
-
#### Add a User Message
|
|
126
|
-
|
|
127
|
-
```python
|
|
128
|
-
session.add_user_message("Hello! How are you?")
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Session – Retrieving Context
|
|
132
|
-
|
|
133
|
-
```python
|
|
134
|
-
context = session.get_context()
|
|
135
|
-
print("Memory used:", context.memory_used)
|
|
136
|
-
print("Context:", context.context)
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
#### Add an Assistant Message
|
|
140
|
-
|
|
141
|
-
```python
|
|
142
|
-
session.add_assistant_message("I'm an assistant. How can I help you?")
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Session – Process Session
|
|
146
|
-
|
|
147
|
-
```python
|
|
148
|
-
session.process()
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Session – Get Status and Messages
|
|
152
|
-
|
|
153
|
-
```python
|
|
154
|
-
status = session.get_status()
|
|
155
|
-
print("Session status:", status)
|
|
156
|
-
|
|
157
|
-
messages = session.get_messages()
|
|
158
|
-
for message in messages:
|
|
159
|
-
print(f"{message.role}: {message.content} at {message.timestamp}")
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## Example Usage with LLMs
|
|
163
|
-
|
|
164
|
-
```python
|
|
165
|
-
import openai
|
|
166
|
-
from recallrai import RecallrAI
|
|
167
|
-
|
|
168
|
-
# Initialize RecallrAI and OpenAI clients
|
|
169
|
-
recallrai_client = RecallrAI(api_key="rai_yourapikey", project_id="project-uuid")
|
|
170
|
-
openai_client = openai.OpenAI(api_key="your-openai-api-key")
|
|
171
|
-
|
|
172
|
-
def chat_with_memory(user_id, session_id=None):
|
|
173
|
-
# Get or create user
|
|
174
|
-
try:
|
|
175
|
-
user = recallrai_client.get_user(user_id)
|
|
176
|
-
except:
|
|
177
|
-
user = recallrai_client.create_user(user_id)
|
|
178
|
-
|
|
179
|
-
# Create a new session or get an existing one
|
|
180
|
-
if session_id:
|
|
181
|
-
session = recallrai_client.get_session(user_id=user_id, session_id=session_id)
|
|
182
|
-
else:
|
|
183
|
-
session = recallrai_client.create_session(user_id=user_id, auto_process_after_minutes=30)
|
|
184
|
-
print(f"Created new session: {session.session_id}")
|
|
185
|
-
|
|
186
|
-
print("Chat session started. Type 'exit' to end the conversation.")
|
|
187
|
-
|
|
188
|
-
while True:
|
|
189
|
-
# Get user input
|
|
190
|
-
user_message = input("You: ")
|
|
191
|
-
if user_message.lower() == 'exit':
|
|
192
|
-
break
|
|
193
|
-
|
|
194
|
-
# Add the user message to RecallrAI
|
|
195
|
-
session.add_user_message(user_message)
|
|
196
|
-
|
|
197
|
-
# Get context from RecallrAI after adding the user message
|
|
198
|
-
context = session.get_context()
|
|
199
|
-
|
|
200
|
-
# Create a system prompt that includes the context
|
|
201
|
-
system_prompt = f"""You are a helpful assistant with memory of previous conversations.
|
|
202
|
-
|
|
203
|
-
MEMORIES ABOUT THE USER:
|
|
204
|
-
{context.context}
|
|
205
|
-
|
|
206
|
-
You can use the above memories to provide better responses to the user.
|
|
207
|
-
Don't mention that you have access to memories unless you are explicitly asked."""
|
|
208
|
-
|
|
209
|
-
# Get previous messages
|
|
210
|
-
previous_messages = session.get_messages()
|
|
211
|
-
previous_messages = [{"role": message.role, "content": message.content} for message in previous_messages]
|
|
212
|
-
|
|
213
|
-
# Call the LLM with the system prompt and user message
|
|
214
|
-
response = openai_client.chat.completions.create(
|
|
215
|
-
model="gpt-4o-mini",
|
|
216
|
-
messages=[
|
|
217
|
-
{"role": "system", "content": system_prompt},
|
|
218
|
-
**previous_messages,
|
|
219
|
-
],
|
|
220
|
-
temperature=0.7
|
|
221
|
-
)
|
|
222
|
-
|
|
223
|
-
assistant_message = response.choices[0].message.content
|
|
224
|
-
|
|
225
|
-
# Print the assistant's response
|
|
226
|
-
print(f"Assistant: {assistant_message}")
|
|
227
|
-
|
|
228
|
-
# Add the assistant's response to RecallrAI
|
|
229
|
-
session.add_assistant_message(assistant_message)
|
|
230
|
-
|
|
231
|
-
# Process the session at the end of the conversation
|
|
232
|
-
print("Processing session to update memory...")
|
|
233
|
-
session.process()
|
|
234
|
-
print(f"Session ended. Session ID: {session.session_id}")
|
|
235
|
-
return session.session_id
|
|
236
|
-
|
|
237
|
-
# Example usage
|
|
238
|
-
if __name__ == "__main__":
|
|
239
|
-
user_id = "user123"
|
|
240
|
-
# To continue a previous session, uncomment below and provide the session ID
|
|
241
|
-
# previous_session_id = "previously-saved-session-uuid"
|
|
242
|
-
# session_id = chat_with_memory(user_id, previous_session_id)
|
|
243
|
-
|
|
244
|
-
# Start a new session
|
|
245
|
-
session_id = chat_with_memory(user_id)
|
|
246
|
-
print(f"To continue this conversation later, use session ID: {session_id}")
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
## Exception Handling
|
|
250
|
-
|
|
251
|
-
> Exception handling will be improved in future.
|
|
252
|
-
Each operation may raise custom exceptions defined in the SDK:
|
|
253
|
-
|
|
254
|
-
```python
|
|
255
|
-
from recallrai.utils.exceptions import NotFoundError, ValidationError
|
|
256
|
-
|
|
257
|
-
try:
|
|
258
|
-
user = client.get_user("nonexistent_id")
|
|
259
|
-
except NotFoundError as e:
|
|
260
|
-
print("User not found:", e.message)
|
|
261
|
-
except ValidationError as e:
|
|
262
|
-
print("Invalid input:", e.message)
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
## Conclusion
|
|
266
|
-
|
|
267
|
-
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).
|
|
268
|
-
|
recallrai-0.1.0.dist-info/RECORD
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
recallrai/__init__.py,sha256=lw4pmQKtKkfTZ50xY3Z3J9IRxaG1XMrvEsN-jSazeHY,385
|
|
2
|
-
recallrai/client.py,sha256=lzD4DYL8kedr6P-9zJbf93CCt9PxmmHcSE2HzKBIU0w,6976
|
|
3
|
-
recallrai/models/__init__.py,sha256=2wwbyVAY4IgBn1a7YcbA4i1_pXJpYPYuQo80N8PVTlI,361
|
|
4
|
-
recallrai/models/session.py,sha256=Okn2tMmnl0UPL9q-Bl4cBaUcgs_U_nnvmKj3CHWavGY,3701
|
|
5
|
-
recallrai/models/user.py,sha256=yu7HzceZ-U2Hp6lbRjA31SQsyfD3dmuBoQ9dVGvfZ14,2190
|
|
6
|
-
recallrai/session.py,sha256=r045TL3a4_g0JjbCJ7VyRdhMX4JsUpVTDmMeeVwpGtY,5690
|
|
7
|
-
recallrai/user.py,sha256=VwQhKSJrwEEV7LgGDHOIRbIfwRi7OE5V-F146CGD8kY,4035
|
|
8
|
-
recallrai/utils/__init__.py,sha256=p_RBdfNvgBWQ62psiokCPCmZI5H7AQm8EJiRLxfHUjA,212
|
|
9
|
-
recallrai/utils/exceptions.py,sha256=b-8ONmtUgcjJxUg68pXwnana-5zt4C0cR2rTliFBGBE,1581
|
|
10
|
-
recallrai/utils/http.py,sha256=dGd4uUWtRDRBLZctNDNfdDr5njekMjCPBYSWcvKRpJM,5513
|
|
11
|
-
recallrai-0.1.0.dist-info/METADATA,sha256=WU87emxQgZ4t5p8k9ipp8MwbbwDLWDmzrWyYzY_-TJg,7801
|
|
12
|
-
recallrai-0.1.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
13
|
-
recallrai-0.1.0.dist-info/RECORD,,
|
|
File without changes
|