mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-01 02:01:40 +00:00
`_field` returns the first value that is not None. A v4 hybrid-search hit
shaped `{"memory": "", "chunk": "..."}` therefore resolves to the empty
string and never falls through to `chunk` — the exact fallback the call
site's comment says it is there for.
The consequences are in both directions. In `deduplicate_memories` the hit
produces an empty comparison key and is dropped, so the memory never reaches
the prompt. When such an item does survive, `format_memories_to_text` renders
it through the same `_field` call and emits a bare `- [16 hrs ago] `.
The TypeScript `getMemoryText` takes the first non-empty field instead, and
`agent-framework-python` and `openai-sdk-python` both already match it; the
two voice SDKs were the only implementations that disagreed. Add a
`_memory_text` helper mirroring the TypeScript semantics and use it on both
the dedup and the render path.
Also add tests/conftest.py to pipecat so the import stubs are installed
regardless of collection order — test_utils.py cannot import the package
on its own otherwise.
103 lines
3.2 KiB
Python
103 lines
3.2 KiB
Python
"""Import stubs for the heavy optional runtime dependencies.
|
|
|
|
CI installs the real `pipecat-ai`, `loguru` and `pydantic`, so every stub
|
|
here is a no-op there. Locally they let the pure-Python helpers under test
|
|
import without the full voice stack, and living in conftest means any test
|
|
module gets them regardless of collection order.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import types
|
|
|
|
|
|
def _install_test_stubs() -> None:
|
|
if "loguru" not in sys.modules:
|
|
loguru_module = types.ModuleType("loguru")
|
|
|
|
class _Logger:
|
|
def warning(self, *_args, **_kwargs):
|
|
return None
|
|
|
|
def error(self, *_args, **_kwargs):
|
|
return None
|
|
|
|
loguru_module.logger = _Logger()
|
|
sys.modules["loguru"] = loguru_module
|
|
|
|
if "pydantic" not in sys.modules:
|
|
pydantic_module = types.ModuleType("pydantic")
|
|
|
|
class BaseModel:
|
|
def __init__(self, **kwargs):
|
|
for key, value in kwargs.items():
|
|
setattr(self, key, value)
|
|
|
|
def Field(*, default=None, **_kwargs):
|
|
return default
|
|
|
|
pydantic_module.BaseModel = BaseModel
|
|
pydantic_module.Field = Field
|
|
sys.modules["pydantic"] = pydantic_module
|
|
|
|
if "pipecat" not in sys.modules:
|
|
pipecat_module = types.ModuleType("pipecat")
|
|
sys.modules["pipecat"] = pipecat_module
|
|
|
|
frames_module = types.ModuleType("pipecat.frames.frames")
|
|
|
|
class Frame: # pragma: no cover - import stub
|
|
pass
|
|
|
|
class InputAudioRawFrame: # pragma: no cover - import stub
|
|
pass
|
|
|
|
class LLMContextFrame: # pragma: no cover - import stub
|
|
pass
|
|
|
|
class LLMMessagesFrame: # pragma: no cover - import stub
|
|
pass
|
|
|
|
frames_module.Frame = Frame
|
|
frames_module.InputAudioRawFrame = InputAudioRawFrame
|
|
frames_module.LLMContextFrame = LLMContextFrame
|
|
frames_module.LLMMessagesFrame = LLMMessagesFrame
|
|
|
|
llm_context_module = types.ModuleType("pipecat.processors.aggregators.llm_context")
|
|
|
|
class LLMContext: # pragma: no cover - import stub
|
|
pass
|
|
|
|
llm_context_module.LLMContext = LLMContext
|
|
|
|
openai_context_module = types.ModuleType(
|
|
"pipecat.processors.aggregators.openai_llm_context"
|
|
)
|
|
|
|
class OpenAILLMContextFrame: # pragma: no cover - import stub
|
|
pass
|
|
|
|
openai_context_module.OpenAILLMContextFrame = OpenAILLMContextFrame
|
|
|
|
frame_processor_module = types.ModuleType("pipecat.processors.frame_processor")
|
|
|
|
class FrameDirection: # pragma: no cover - import stub
|
|
pass
|
|
|
|
class FrameProcessor:
|
|
def __init__(self, *args, **kwargs):
|
|
return None
|
|
|
|
frame_processor_module.FrameDirection = FrameDirection
|
|
frame_processor_module.FrameProcessor = FrameProcessor
|
|
|
|
sys.modules["pipecat.frames.frames"] = frames_module
|
|
sys.modules["pipecat.processors.aggregators.llm_context"] = llm_context_module
|
|
sys.modules[
|
|
"pipecat.processors.aggregators.openai_llm_context"
|
|
] = openai_context_module
|
|
sys.modules["pipecat.processors.frame_processor"] = frame_processor_module
|
|
|
|
|
|
_install_test_stubs()
|