recallrai 0.0.1__tar.gz → 0.1.0__tar.gz

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,268 @@
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
+
@@ -0,0 +1,242 @@
1
+ # RecallrAI Python SDK
2
+
3
+ Official Python SDK for RecallrAI – a revolutionary contextual memory system that enables AI assistants to form meaningful connections between conversations, just like human memory.
4
+
5
+ ## Installation
6
+
7
+ Install the SDK via Poetry or pip:
8
+
9
+ ```bash
10
+ poetry add recallrai
11
+ # or
12
+ pip install recallrai
13
+ ```
14
+
15
+ ## Initialization
16
+
17
+ Create a client instance with your API key and project ID:
18
+
19
+ ```python
20
+ from recallrai import RecallrAI
21
+
22
+ api_key = "rai_yourapikey"
23
+ project_id = "project-uuid"
24
+ client = RecallrAI(api_key=api_key, project_id=project_id)
25
+ ```
26
+
27
+ ## User Management
28
+
29
+ ### Create a User
30
+
31
+ ```python
32
+ from recallrai.user import User
33
+
34
+ user_id = "user123"
35
+ metadata = {"key": "value"}
36
+ user = client.create_user(user_id=user_id, metadata=metadata)
37
+ print("Created user:", user.user_id)
38
+ ```
39
+
40
+ ### Get a User
41
+
42
+ ```python
43
+ user = client.get_user("user123")
44
+ print("User metadata:", user.metadata)
45
+ ```
46
+
47
+ ### List Users
48
+
49
+ ```python
50
+ user_list = client.list_users(offset=0, limit=10)
51
+ for user in user_list.users:
52
+ print(user.user_id, user.metadata)
53
+ ```
54
+
55
+ ### Update a User
56
+
57
+ ```python
58
+ # Update the user's metadata and/or change the user ID
59
+ updated_user = client.update_user(user_id="user123", new_metadata={"role": "user"}, new_user_id="user1234")
60
+ print("Updated user id:", updated_user.user_id)
61
+ ```
62
+
63
+ ### Delete a User
64
+
65
+ ```python
66
+ client.delete_user("user1234")
67
+ print("User deleted.")
68
+ ```
69
+
70
+ ## Session Management
71
+
72
+ ### Create a Session
73
+
74
+ ```python
75
+ from recallrai.session import Session
76
+
77
+ # Create a session for a user; auto_process_after_minutes set to -1 disables auto-processing.
78
+ session = client.create_session(user_id="user123", auto_process_after_minutes=5)
79
+ print("Created session id:", session.session_id)
80
+ ```
81
+
82
+ ### Get an Existing Session
83
+
84
+ ```python
85
+ # Retrieve an existing session by its ID
86
+ session = client.get_session(user_id="user123", session_id="session-uuid")
87
+ print("Session status:", session.get_status())
88
+ ```
89
+
90
+ ### List Sessions
91
+
92
+ ```python
93
+ session_list = client.list_sessions(user_id="user123", offset=0, limit=10)
94
+ for session in session_list.sessions:
95
+ print(session.session_id, session.status)
96
+ ```
97
+
98
+ ### Session – Adding Messages
99
+
100
+ #### Add a User Message
101
+
102
+ ```python
103
+ session.add_user_message("Hello! How are you?")
104
+ ```
105
+
106
+ ### Session – Retrieving Context
107
+
108
+ ```python
109
+ context = session.get_context()
110
+ print("Memory used:", context.memory_used)
111
+ print("Context:", context.context)
112
+ ```
113
+
114
+ #### Add an Assistant Message
115
+
116
+ ```python
117
+ session.add_assistant_message("I'm an assistant. How can I help you?")
118
+ ```
119
+
120
+ ### Session – Process Session
121
+
122
+ ```python
123
+ session.process()
124
+ ```
125
+
126
+ ### Session – Get Status and Messages
127
+
128
+ ```python
129
+ status = session.get_status()
130
+ print("Session status:", status)
131
+
132
+ messages = session.get_messages()
133
+ for message in messages:
134
+ print(f"{message.role}: {message.content} at {message.timestamp}")
135
+ ```
136
+
137
+ ## Example Usage with LLMs
138
+
139
+ ```python
140
+ import openai
141
+ from recallrai import RecallrAI
142
+
143
+ # Initialize RecallrAI and OpenAI clients
144
+ recallrai_client = RecallrAI(api_key="rai_yourapikey", project_id="project-uuid")
145
+ openai_client = openai.OpenAI(api_key="your-openai-api-key")
146
+
147
+ def chat_with_memory(user_id, session_id=None):
148
+ # Get or create user
149
+ try:
150
+ user = recallrai_client.get_user(user_id)
151
+ except:
152
+ user = recallrai_client.create_user(user_id)
153
+
154
+ # Create a new session or get an existing one
155
+ if session_id:
156
+ session = recallrai_client.get_session(user_id=user_id, session_id=session_id)
157
+ else:
158
+ session = recallrai_client.create_session(user_id=user_id, auto_process_after_minutes=30)
159
+ print(f"Created new session: {session.session_id}")
160
+
161
+ print("Chat session started. Type 'exit' to end the conversation.")
162
+
163
+ while True:
164
+ # Get user input
165
+ user_message = input("You: ")
166
+ if user_message.lower() == 'exit':
167
+ break
168
+
169
+ # Add the user message to RecallrAI
170
+ session.add_user_message(user_message)
171
+
172
+ # Get context from RecallrAI after adding the user message
173
+ context = session.get_context()
174
+
175
+ # Create a system prompt that includes the context
176
+ system_prompt = f"""You are a helpful assistant with memory of previous conversations.
177
+
178
+ MEMORIES ABOUT THE USER:
179
+ {context.context}
180
+
181
+ You can use the above memories to provide better responses to the user.
182
+ Don't mention that you have access to memories unless you are explicitly asked."""
183
+
184
+ # Get previous messages
185
+ previous_messages = session.get_messages()
186
+ previous_messages = [{"role": message.role, "content": message.content} for message in previous_messages]
187
+
188
+ # Call the LLM with the system prompt and user message
189
+ response = openai_client.chat.completions.create(
190
+ model="gpt-4o-mini",
191
+ messages=[
192
+ {"role": "system", "content": system_prompt},
193
+ **previous_messages,
194
+ ],
195
+ temperature=0.7
196
+ )
197
+
198
+ assistant_message = response.choices[0].message.content
199
+
200
+ # Print the assistant's response
201
+ print(f"Assistant: {assistant_message}")
202
+
203
+ # Add the assistant's response to RecallrAI
204
+ session.add_assistant_message(assistant_message)
205
+
206
+ # Process the session at the end of the conversation
207
+ print("Processing session to update memory...")
208
+ session.process()
209
+ print(f"Session ended. Session ID: {session.session_id}")
210
+ return session.session_id
211
+
212
+ # Example usage
213
+ if __name__ == "__main__":
214
+ user_id = "user123"
215
+ # To continue a previous session, uncomment below and provide the session ID
216
+ # previous_session_id = "previously-saved-session-uuid"
217
+ # session_id = chat_with_memory(user_id, previous_session_id)
218
+
219
+ # Start a new session
220
+ session_id = chat_with_memory(user_id)
221
+ print(f"To continue this conversation later, use session ID: {session_id}")
222
+ ```
223
+
224
+ ## Exception Handling
225
+
226
+ > Exception handling will be improved in future.
227
+ Each operation may raise custom exceptions defined in the SDK:
228
+
229
+ ```python
230
+ from recallrai.utils.exceptions import NotFoundError, ValidationError
231
+
232
+ try:
233
+ user = client.get_user("nonexistent_id")
234
+ except NotFoundError as e:
235
+ print("User not found:", e.message)
236
+ except ValidationError as e:
237
+ print("Invalid input:", e.message)
238
+ ```
239
+
240
+ ## Conclusion
241
+
242
+ 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).
@@ -0,0 +1,34 @@
1
+ [tool.poetry]
2
+ name = "recallrai"
3
+ version = "0.1.0"
4
+ description = "Official Python SDK for RecallrAI - Revolutionary contextual memory system that enables AI assistants to form meaningful connections between conversations, just like human memory."
5
+ authors = ["Devasheesh Mishra <devasheeshmishra4@gmail.com>"]
6
+ license = "MIT License"
7
+ readme = "README.md"
8
+ repository = "https://github.com/recallrai/sdk-python"
9
+ keywords = ["ai", "memory", "context", "llm", "mem0", "getzep", "zep"]
10
+ homepage = "https://recallrai.com"
11
+ classifiers = [
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.8",
14
+ "Programming Language :: Python :: 3.9",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Intended Audience :: Developers",
20
+ ]
21
+ package-mode = true
22
+
23
+ [tool.poetry.dependencies]
24
+ python = ">=3.8,<4.0"
25
+ httpx = "^0.25.0"
26
+ pydantic = "^2.4.0"
27
+
28
+ [tool.poetry.group.dev.dependencies]
29
+ twine = "^5.1.1"
30
+ ipykernel = "^6.29.5"
31
+
32
+ [build-system]
33
+ requires = ["poetry-core"]
34
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,19 @@
1
+ # Path: recallrai/__init__.py
2
+ # Description: Package initialization file with SDK version and main class exports
3
+
4
+ """
5
+ RecallrAI Python SDK
6
+
7
+ This package provides a Python interface to interact with the RecallrAI API.
8
+ """
9
+
10
+ from .client import RecallrAI
11
+ from .user import User
12
+ from .session import Session
13
+
14
+ __version__ = "0.1.0"
15
+ __all__ = [
16
+ "RecallrAI",
17
+ "User",
18
+ "Session",
19
+ ]