supermemory-openai-sdk 1.0.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.
@@ -0,0 +1,43 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+ .open-next/
3
+ .sentryclirc
4
+
5
+ # Dependencies
6
+ node_modules
7
+ .pnp
8
+ .pnp.js
9
+
10
+ # Local env files
11
+ .env
12
+ .env.local
13
+ .env.development.local
14
+ .env.test.local
15
+ .env.production.local
16
+
17
+ # Testing
18
+ coverage
19
+
20
+ # Turbo
21
+ .turbo
22
+
23
+ # Vercel
24
+ .vercel
25
+
26
+ # Build Outputs
27
+ .next/
28
+ out/
29
+ build
30
+ dist
31
+
32
+
33
+ # Debug
34
+ npm-debug.log*
35
+ yarn-debug.log*
36
+ yarn-error.log*
37
+
38
+ # Misc
39
+ .DS_Store
40
+ *.pem
41
+
42
+ .venv
43
+ __pycache__
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Supermemory Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,256 @@
1
+ Metadata-Version: 2.4
2
+ Name: supermemory-openai-sdk
3
+ Version: 1.0.0
4
+ Summary: Memory tools for OpenAI function calling with supermemory
5
+ Project-URL: Homepage, https://supermemory.ai
6
+ Project-URL: Repository, https://github.com/supermemoryai/supermemory
7
+ Project-URL: Documentation, https://supermemory.ai/docs
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: ai,memory,openai,supermemory
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.8.1
23
+ Requires-Dist: openai>=1.102.0
24
+ Requires-Dist: supermemory>=3.0.0a28
25
+ Requires-Dist: typing-extensions>=4.0.0
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Supermemory OpenAI Python SDK
29
+
30
+ Memory tools for OpenAI function calling with Supermemory integration.
31
+
32
+ This package provides memory management tools for the official [OpenAI Python SDK](https://github.com/openai/openai-python) using [Supermemory](https://supermemory.ai) capabilities.
33
+
34
+ ## Installation
35
+
36
+ Install using uv (recommended):
37
+
38
+ ```bash
39
+ uv add supermemory-openai
40
+ ```
41
+
42
+ Or with pip:
43
+
44
+ ```bash
45
+ pip install supermemory-openai
46
+ ```
47
+
48
+ ## Quick Start
49
+
50
+ ### Using Memory Tools with OpenAI
51
+
52
+ ```python
53
+ import asyncio
54
+ import openai
55
+ from supermemory_openai import SupermemoryTools, execute_memory_tool_calls
56
+
57
+ async def main():
58
+ # Initialize OpenAI client
59
+ client = openai.AsyncOpenAI(api_key="your-openai-api-key")
60
+
61
+ # Initialize Supermemory tools
62
+ tools = SupermemoryTools(
63
+ api_key="your-supermemory-api-key",
64
+ config={"project_id": "my-project"}
65
+ )
66
+
67
+ # Chat with memory tools
68
+ response = await client.chat.completions.create(
69
+ model="gpt-4o",
70
+ messages=[
71
+ {
72
+ "role": "system",
73
+ "content": "You are a helpful assistant with access to user memories."
74
+ },
75
+ {
76
+ "role": "user",
77
+ "content": "Remember that I prefer tea over coffee"
78
+ }
79
+ ],
80
+ tools=tools.get_tool_definitions()
81
+ )
82
+
83
+ # Handle tool calls if present
84
+ if response.choices[0].message.tool_calls:
85
+ tool_results = await execute_memory_tool_calls(
86
+ api_key="your-supermemory-api-key",
87
+ tool_calls=response.choices[0].message.tool_calls,
88
+ config={"project_id": "my-project"}
89
+ )
90
+ print("Tool results:", tool_results)
91
+
92
+ print(response.choices[0].message.content)
93
+
94
+ asyncio.run(main())
95
+ ```
96
+
97
+ ## Configuration
98
+
99
+ ## Memory Tools
100
+
101
+ ### SupermemoryTools Class
102
+
103
+ ```python
104
+ from supermemory_openai import SupermemoryTools
105
+
106
+ tools = SupermemoryTools(
107
+ api_key="your-supermemory-api-key",
108
+ config={
109
+ "project_id": "my-project", # or use container_tags
110
+ "base_url": "https://custom-endpoint.com", # optional
111
+ }
112
+ )
113
+
114
+ # Search memories
115
+ result = await tools.search_memories(
116
+ information_to_get="user preferences",
117
+ limit=10,
118
+ include_full_docs=True
119
+ )
120
+
121
+ # Add memory
122
+ result = await tools.add_memory(
123
+ memory="User prefers tea over coffee"
124
+ )
125
+
126
+ # Fetch specific memory
127
+ result = await tools.fetch_memory(
128
+ memory_id="memory-id-here"
129
+ )
130
+ ```
131
+
132
+ ### Individual Tools
133
+
134
+ ```python
135
+ from supermemory_openai import (
136
+ create_search_memories_tool,
137
+ create_add_memory_tool,
138
+ create_fetch_memory_tool
139
+ )
140
+
141
+ search_tool = create_search_memories_tool("your-api-key")
142
+ add_tool = create_add_memory_tool("your-api-key")
143
+ fetch_tool = create_fetch_memory_tool("your-api-key")
144
+ ```
145
+
146
+ ### Function Calling Integration
147
+
148
+ ```python
149
+ from supermemory_openai import execute_memory_tool_calls
150
+
151
+ # After getting tool calls from OpenAI
152
+ if response.choices[0].message.tool_calls:
153
+ tool_results = await execute_memory_tool_calls(
154
+ api_key="your-supermemory-api-key",
155
+ tool_calls=response.choices[0].message.tool_calls,
156
+ config={"project_id": "my-project"}
157
+ )
158
+
159
+ # Add tool results to conversation
160
+ messages.append(response.choices[0].message)
161
+ messages.extend(tool_results)
162
+ ```
163
+
164
+ ## API Reference
165
+
166
+ ### SupermemoryTools
167
+
168
+ Memory management tools for function calling.
169
+
170
+ #### Constructor
171
+
172
+ ```python
173
+ SupermemoryTools(
174
+ api_key: str,
175
+ config: Optional[SupermemoryToolsConfig] = None
176
+ )
177
+ ```
178
+
179
+ #### Methods
180
+
181
+ - `get_tool_definitions()` - Get OpenAI function definitions
182
+ - `search_memories()` - Search user memories
183
+ - `add_memory()` - Add new memory
184
+ - `fetch_memory()` - Fetch specific memory by ID
185
+ - `execute_tool_call()` - Execute individual tool call
186
+
187
+ ## Error Handling
188
+
189
+ ```python
190
+ try:
191
+ response = await client.chat_completion(
192
+ messages=[{"role": "user", "content": "Hello"}],
193
+ model="gpt-4o"
194
+ )
195
+ except Exception as e:
196
+ print(f"Error: {e}")
197
+ ```
198
+
199
+ ## Environment Variables
200
+
201
+ Set these environment variables for testing:
202
+
203
+ - `SUPERMEMORY_API_KEY` - Your Supermemory API key
204
+ - `OPENAI_API_KEY` - Your OpenAI API key
205
+ - `MODEL_NAME` - Model to use (default: "gpt-4o-mini")
206
+ - `SUPERMEMORY_BASE_URL` - Custom Supermemory base URL (optional)
207
+
208
+ ## Development
209
+
210
+ ### Setup
211
+
212
+ ```bash
213
+ # Install uv
214
+ curl -LsSf https://astral.sh/uv/install.sh | sh
215
+
216
+ # Clone and setup
217
+ git clone <repository-url>
218
+ cd packages/openai-sdk-python
219
+ uv sync --dev
220
+ ```
221
+
222
+ ### Testing
223
+
224
+ ```bash
225
+ # Run tests
226
+ uv run pytest
227
+
228
+ # Run with coverage
229
+ uv run pytest --cov=supermemory_openai
230
+
231
+ # Run specific test file
232
+ uv run pytest tests/test_infinite_chat.py
233
+ ```
234
+
235
+ ### Type Checking
236
+
237
+ ```bash
238
+ uv run mypy src/supermemory_openai
239
+ ```
240
+
241
+ ### Formatting
242
+
243
+ ```bash
244
+ uv run black src/ tests/
245
+ uv run isort src/ tests/
246
+ ```
247
+
248
+ ## License
249
+
250
+ MIT License - see LICENSE file for details.
251
+
252
+ ## Links
253
+
254
+ - [Supermemory](https://supermemory.ai) - Infinite context memory platform
255
+ - [OpenAI Python SDK](https://github.com/openai/openai-python) - Official OpenAI Python library
256
+ - [Documentation](https://docs.supermemory.ai) - Full API documentation
@@ -0,0 +1,229 @@
1
+ # Supermemory OpenAI Python SDK
2
+
3
+ Memory tools for OpenAI function calling with Supermemory integration.
4
+
5
+ This package provides memory management tools for the official [OpenAI Python SDK](https://github.com/openai/openai-python) using [Supermemory](https://supermemory.ai) capabilities.
6
+
7
+ ## Installation
8
+
9
+ Install using uv (recommended):
10
+
11
+ ```bash
12
+ uv add supermemory-openai
13
+ ```
14
+
15
+ Or with pip:
16
+
17
+ ```bash
18
+ pip install supermemory-openai
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### Using Memory Tools with OpenAI
24
+
25
+ ```python
26
+ import asyncio
27
+ import openai
28
+ from supermemory_openai import SupermemoryTools, execute_memory_tool_calls
29
+
30
+ async def main():
31
+ # Initialize OpenAI client
32
+ client = openai.AsyncOpenAI(api_key="your-openai-api-key")
33
+
34
+ # Initialize Supermemory tools
35
+ tools = SupermemoryTools(
36
+ api_key="your-supermemory-api-key",
37
+ config={"project_id": "my-project"}
38
+ )
39
+
40
+ # Chat with memory tools
41
+ response = await client.chat.completions.create(
42
+ model="gpt-4o",
43
+ messages=[
44
+ {
45
+ "role": "system",
46
+ "content": "You are a helpful assistant with access to user memories."
47
+ },
48
+ {
49
+ "role": "user",
50
+ "content": "Remember that I prefer tea over coffee"
51
+ }
52
+ ],
53
+ tools=tools.get_tool_definitions()
54
+ )
55
+
56
+ # Handle tool calls if present
57
+ if response.choices[0].message.tool_calls:
58
+ tool_results = await execute_memory_tool_calls(
59
+ api_key="your-supermemory-api-key",
60
+ tool_calls=response.choices[0].message.tool_calls,
61
+ config={"project_id": "my-project"}
62
+ )
63
+ print("Tool results:", tool_results)
64
+
65
+ print(response.choices[0].message.content)
66
+
67
+ asyncio.run(main())
68
+ ```
69
+
70
+ ## Configuration
71
+
72
+ ## Memory Tools
73
+
74
+ ### SupermemoryTools Class
75
+
76
+ ```python
77
+ from supermemory_openai import SupermemoryTools
78
+
79
+ tools = SupermemoryTools(
80
+ api_key="your-supermemory-api-key",
81
+ config={
82
+ "project_id": "my-project", # or use container_tags
83
+ "base_url": "https://custom-endpoint.com", # optional
84
+ }
85
+ )
86
+
87
+ # Search memories
88
+ result = await tools.search_memories(
89
+ information_to_get="user preferences",
90
+ limit=10,
91
+ include_full_docs=True
92
+ )
93
+
94
+ # Add memory
95
+ result = await tools.add_memory(
96
+ memory="User prefers tea over coffee"
97
+ )
98
+
99
+ # Fetch specific memory
100
+ result = await tools.fetch_memory(
101
+ memory_id="memory-id-here"
102
+ )
103
+ ```
104
+
105
+ ### Individual Tools
106
+
107
+ ```python
108
+ from supermemory_openai import (
109
+ create_search_memories_tool,
110
+ create_add_memory_tool,
111
+ create_fetch_memory_tool
112
+ )
113
+
114
+ search_tool = create_search_memories_tool("your-api-key")
115
+ add_tool = create_add_memory_tool("your-api-key")
116
+ fetch_tool = create_fetch_memory_tool("your-api-key")
117
+ ```
118
+
119
+ ### Function Calling Integration
120
+
121
+ ```python
122
+ from supermemory_openai import execute_memory_tool_calls
123
+
124
+ # After getting tool calls from OpenAI
125
+ if response.choices[0].message.tool_calls:
126
+ tool_results = await execute_memory_tool_calls(
127
+ api_key="your-supermemory-api-key",
128
+ tool_calls=response.choices[0].message.tool_calls,
129
+ config={"project_id": "my-project"}
130
+ )
131
+
132
+ # Add tool results to conversation
133
+ messages.append(response.choices[0].message)
134
+ messages.extend(tool_results)
135
+ ```
136
+
137
+ ## API Reference
138
+
139
+ ### SupermemoryTools
140
+
141
+ Memory management tools for function calling.
142
+
143
+ #### Constructor
144
+
145
+ ```python
146
+ SupermemoryTools(
147
+ api_key: str,
148
+ config: Optional[SupermemoryToolsConfig] = None
149
+ )
150
+ ```
151
+
152
+ #### Methods
153
+
154
+ - `get_tool_definitions()` - Get OpenAI function definitions
155
+ - `search_memories()` - Search user memories
156
+ - `add_memory()` - Add new memory
157
+ - `fetch_memory()` - Fetch specific memory by ID
158
+ - `execute_tool_call()` - Execute individual tool call
159
+
160
+ ## Error Handling
161
+
162
+ ```python
163
+ try:
164
+ response = await client.chat_completion(
165
+ messages=[{"role": "user", "content": "Hello"}],
166
+ model="gpt-4o"
167
+ )
168
+ except Exception as e:
169
+ print(f"Error: {e}")
170
+ ```
171
+
172
+ ## Environment Variables
173
+
174
+ Set these environment variables for testing:
175
+
176
+ - `SUPERMEMORY_API_KEY` - Your Supermemory API key
177
+ - `OPENAI_API_KEY` - Your OpenAI API key
178
+ - `MODEL_NAME` - Model to use (default: "gpt-4o-mini")
179
+ - `SUPERMEMORY_BASE_URL` - Custom Supermemory base URL (optional)
180
+
181
+ ## Development
182
+
183
+ ### Setup
184
+
185
+ ```bash
186
+ # Install uv
187
+ curl -LsSf https://astral.sh/uv/install.sh | sh
188
+
189
+ # Clone and setup
190
+ git clone <repository-url>
191
+ cd packages/openai-sdk-python
192
+ uv sync --dev
193
+ ```
194
+
195
+ ### Testing
196
+
197
+ ```bash
198
+ # Run tests
199
+ uv run pytest
200
+
201
+ # Run with coverage
202
+ uv run pytest --cov=supermemory_openai
203
+
204
+ # Run specific test file
205
+ uv run pytest tests/test_infinite_chat.py
206
+ ```
207
+
208
+ ### Type Checking
209
+
210
+ ```bash
211
+ uv run mypy src/supermemory_openai
212
+ ```
213
+
214
+ ### Formatting
215
+
216
+ ```bash
217
+ uv run black src/ tests/
218
+ uv run isort src/ tests/
219
+ ```
220
+
221
+ ## License
222
+
223
+ MIT License - see LICENSE file for details.
224
+
225
+ ## Links
226
+
227
+ - [Supermemory](https://supermemory.ai) - Infinite context memory platform
228
+ - [OpenAI Python SDK](https://github.com/openai/openai-python) - Official OpenAI Python library
229
+ - [Documentation](https://docs.supermemory.ai) - Full API documentation
@@ -0,0 +1,96 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "supermemory-openai-sdk"
7
+ version = "1.0.0"
8
+ description = "Memory tools for OpenAI function calling with supermemory"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ keywords = ["openai", "supermemory", "ai", "memory"]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ ]
26
+ requires-python = ">=3.8.1"
27
+ dependencies = [
28
+ "openai>=1.102.0",
29
+ "supermemory>=3.0.0a28",
30
+ "typing-extensions>=4.0.0",
31
+ ]
32
+
33
+ [dependency-groups]
34
+ dev = [
35
+ "black>=24.8.0",
36
+ "flake8>=7.1.2",
37
+ "isort>=5.13.2",
38
+ "mypy>=1.14.1",
39
+ "pytest>=8.3.5",
40
+ "pytest-asyncio>=0.24.0",
41
+ "python-dotenv>=1.0.1",
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://supermemory.ai"
46
+ Repository = "https://github.com/supermemoryai/supermemory"
47
+ Documentation = "https://supermemory.ai/docs"
48
+
49
+ [tool.hatch.build.targets.wheel]
50
+ packages = ["src"]
51
+
52
+ [tool.black]
53
+ line-length = 88
54
+ target-version = ['py38']
55
+ include = '\.pyi?$'
56
+ extend-exclude = '''
57
+ /(
58
+ # directories
59
+ \.eggs
60
+ | \.git
61
+ | \.hg
62
+ | \.mypy_cache
63
+ | \.tox
64
+ | \.venv
65
+ | build
66
+ | dist
67
+ )/
68
+ '''
69
+
70
+ [tool.isort]
71
+ profile = "black"
72
+ multi_line_output = 3
73
+ line_length = 88
74
+
75
+ [tool.mypy]
76
+ python_version = "3.8"
77
+ warn_return_any = true
78
+ warn_unused_configs = true
79
+ disallow_untyped_defs = true
80
+ disallow_incomplete_defs = true
81
+ check_untyped_defs = true
82
+ disallow_untyped_decorators = true
83
+ no_implicit_optional = true
84
+ warn_redundant_casts = true
85
+ warn_unused_ignores = true
86
+ warn_no_return = true
87
+ warn_unreachable = true
88
+ strict_equality = true
89
+
90
+ [tool.pytest.ini_options]
91
+ testpaths = ["tests"]
92
+ python_files = ["test_*.py", "*_test.py"]
93
+ python_classes = ["Test*"]
94
+ python_functions = ["test_*"]
95
+ addopts = "-v --tb=short"
96
+ asyncio_mode = "auto"
@@ -0,0 +1,36 @@
1
+ """Supermemory OpenAI SDK - Memory tools for OpenAI function calling."""
2
+
3
+ from .tools import (
4
+ SupermemoryTools,
5
+ SupermemoryToolsConfig,
6
+ MemoryObject,
7
+ MemorySearchResult,
8
+ MemoryAddResult,
9
+ SearchMemoriesTool,
10
+ AddMemoryTool,
11
+ MEMORY_TOOL_SCHEMAS,
12
+ create_supermemory_tools,
13
+ get_memory_tool_definitions,
14
+ execute_memory_tool_calls,
15
+ create_search_memories_tool,
16
+ create_add_memory_tool,
17
+ )
18
+
19
+ __version__ = "0.1.0"
20
+
21
+ __all__ = [
22
+ # Tools
23
+ "SupermemoryTools",
24
+ "SupermemoryToolsConfig",
25
+ "MemoryObject",
26
+ "MemorySearchResult",
27
+ "MemoryAddResult",
28
+ "SearchMemoriesTool",
29
+ "AddMemoryTool",
30
+ "MEMORY_TOOL_SCHEMAS",
31
+ "create_supermemory_tools",
32
+ "get_memory_tool_definitions",
33
+ "execute_memory_tool_calls",
34
+ "create_search_memories_tool",
35
+ "create_add_memory_tool",
36
+ ]