Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def add_memory_tool(
add_params["custom_id"] = custom_id

# Handle both sync and async supermemory clients
result = client.add(**add_params)
result = client.memories.add(**add_params)
if inspect.isawaitable(result):
response = await result
else:
Expand Down
12 changes: 4 additions & 8 deletions packages/openai-sdk-python/src/supermemory_openai/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(self, api_key: str, config: Optional[SupermemoryToolsConfig] = None
if config.get("base_url"):
client_kwargs["base_url"] = config["base_url"]

self.client = supermemory.Supermemory(**client_kwargs)
self.client = supermemory.AsyncSupermemory(**client_kwargs)

# Set container tags
if config.get("project_id"):
Expand Down Expand Up @@ -197,7 +197,7 @@ async def search_memories(

return MemorySearchResult(
success=True,
results=response.results,
results=[r.model_dump() for r in response.results],
count=len(response.results),
)
except (OSError, ConnectionError) as network_error:
Expand All @@ -221,20 +221,16 @@ async def add_memory(self, memory: str) -> MemoryAddResult:
MemoryAddResult
"""
try:
metadata: Dict[str, object] = {}

add_params = {
"content": memory,
"container_tags": self.container_tags,
}
if metadata:
add_params["metadata"] = metadata

response: MemoryAddResponse = await self.client.add(**add_params)
response: MemoryAddResponse = await self.client.memories.add(**add_params)

return MemoryAddResult(
success=True,
memory=response,
memory=response.model_dump(),
)
except (OSError, ConnectionError) as network_error:
return MemoryAddResult(
Expand Down
12 changes: 6 additions & 6 deletions packages/openai-sdk-python/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

# Import from the installed package or src directly
try:
# Try importing from the installed package first
from supermemory_openai_sdk import (
from supermemory_openai import (
SupermemoryTools,
SupermemoryToolsConfig,
create_supermemory_tools,
Expand All @@ -23,13 +22,14 @@
create_add_memory_tool,
)
except ImportError:
# Fallback to importing from src directory
import sys
import os

# Add src directory to path
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src"))
from tools import (
sys.path.insert(
0,
os.path.join(os.path.dirname(os.path.dirname(__file__)), "src"),
)
from supermemory_openai.tools import (
SupermemoryTools,
SupermemoryToolsConfig,
create_supermemory_tools,
Expand Down