mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-11-04 07:30:17 +00:00
The pipecat, cartesia, and agent-framework packages passed search results into dedup/format helpers written for plain dicts, but typed SDK results are pydantic models (snake_case attributes, no dict interface). pipecat and cartesia crashed with AttributeError — swallowed upstream, so no memories were ever injected for users with search results — while agent-framework silently dropped every search-result memory. Extract memory fields through a tolerant accessor that accepts both the camelCase dicts returned by the profile endpoint and SDK result models, so the helpers work regardless of installed SDK version. The pipecat/cartesia dependency stubs move from test_empty_profile.py into a shared tests/conftest.py so the new utils tests can reuse them. Fixes #1266
34 lines
No EOL
1,004 B
Python
34 lines
No EOL
1,004 B
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from types import SimpleNamespace
|
|
from unittest.mock import AsyncMock
|
|
|
|
from .conftest import _install_test_stubs
|
|
|
|
_install_test_stubs()
|
|
|
|
from supermemory_pipecat.service import SupermemoryPipecatService
|
|
|
|
|
|
class _MockSupermemoryClient:
|
|
def __init__(self, response):
|
|
self.profile = AsyncMock(return_value=response)
|
|
|
|
|
|
class TestSupermemoryPipecatNullProfile(unittest.IsolatedAsyncioTestCase):
|
|
async def test_retrieve_memories_handles_null_profile(self) -> None:
|
|
service = SupermemoryPipecatService(api_key="mock_key", user_id="new_user_123")
|
|
|
|
response = SimpleNamespace(profile=None, search_results=None)
|
|
service._supermemory_client = _MockSupermemoryClient(response)
|
|
|
|
result = await service._retrieve_memories("Hello world")
|
|
|
|
self.assertEqual(
|
|
result,
|
|
{
|
|
"profile": {"static": [], "dynamic": []},
|
|
"search_results": [],
|
|
},
|
|
) |