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
5 changes: 5 additions & 0 deletions src/memos/mem_os/utils/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ def get_default_cube_config(
},
}

else:
raise ValueError(
f"text_mem_type must be 'tree_text' or 'general_text', got {text_mem_type!r}"
)

# Configure activation memory if enabled.
# KV cache activation memory requires a local HuggingFace/vLLM model (it
# extracts internal attention KV tensors via build_kv_cache), so it cannot
Expand Down
17 changes: 17 additions & 0 deletions tests/mem_os/test_default_config_text_mem_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pytest

from memos.mem_os.utils.default_config import get_default_cube_config


@pytest.mark.parametrize("bad_type", ["tree-text", "Tree_Text", ""])
def test_invalid_text_mem_type_raises_clear_error(bad_type):
# an unrecognized text_mem_type used to crash with a bare
# UnboundLocalError because text_mem_config was never assigned
with pytest.raises(ValueError, match="text_mem_type must be"):
get_default_cube_config(openai_api_key="sk-x", text_mem_type=bad_type)


@pytest.mark.parametrize("mem_type", ["tree_text", "general_text"])
def test_valid_text_mem_types_build_cube_config(mem_type):
config = get_default_cube_config(openai_api_key="sk-x", text_mem_type=mem_type)
assert config.text_mem.backend == mem_type
Loading