555e282cc4
pi-agent-plugin checks / lint (push) Has been cancelled
pi-agent-plugin checks / test (20) (push) Has been cancelled
pi-agent-plugin checks / test (22) (push) Has been cancelled
pi-agent-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / check_changes (push) Has been cancelled
TypeScript SDK CI / changelog_check (push) Has been cancelled
ci / changelog_check (push) Has been cancelled
ci / check_changes (push) Has been cancelled
ci / build_mem0 (3.10) (push) Has been cancelled
ci / build_mem0 (3.11) (push) Has been cancelled
ci / build_mem0 (3.12) (push) Has been cancelled
CLI Node CI / lint (push) Has been cancelled
CLI Node CI / test (20) (push) Has been cancelled
CLI Node CI / test (22) (push) Has been cancelled
CLI Node CI / build (push) Has been cancelled
CLI Python CI / lint (push) Has been cancelled
CLI Python CI / test (3.10) (push) Has been cancelled
CLI Python CI / test (3.11) (push) Has been cancelled
CLI Python CI / test (3.12) (push) Has been cancelled
CLI Python CI / build (push) Has been cancelled
openclaw checks / lint (push) Has been cancelled
openclaw checks / test (20) (push) Has been cancelled
openclaw checks / test (22) (push) Has been cancelled
openclaw checks / build (push) Has been cancelled
opencode-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (22) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (22) (push) Has been cancelled
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
from unittest.mock import Mock, patch
|
|
|
|
from mem0.configs.llms.anthropic import AnthropicConfig
|
|
from mem0.configs.llms.aws_bedrock import AWSBedrockConfig
|
|
from mem0.configs.llms.base import BaseLlmConfig
|
|
from mem0.configs.llms.openai import OpenAIConfig
|
|
from mem0.utils.factory import LlmFactory
|
|
|
|
|
|
def _capture_config(provider_name, config):
|
|
"""Build an LLM via the factory and return the config it was constructed with."""
|
|
captured = {}
|
|
|
|
def fake_llm_class(built_config):
|
|
captured["config"] = built_config
|
|
return Mock()
|
|
|
|
with patch("mem0.utils.factory.load_class", return_value=fake_llm_class):
|
|
LlmFactory.create(provider_name, config)
|
|
|
|
return captured["config"]
|
|
|
|
|
|
def test_base_to_openai_preserves_reasoning_fields():
|
|
base_config = BaseLlmConfig(model="o3", reasoning_effort="high", is_reasoning_model=True)
|
|
|
|
built = _capture_config("openai", base_config)
|
|
|
|
assert isinstance(built, OpenAIConfig)
|
|
assert built.reasoning_effort == "high"
|
|
assert built.is_reasoning_model is True
|
|
|
|
|
|
def test_base_to_kwargs_provider_preserves_reasoning_fields():
|
|
# AWSBedrockConfig accepts the reasoning fields via **kwargs, so they must survive.
|
|
base_config = BaseLlmConfig(model="amazon.nova", reasoning_effort="medium", is_reasoning_model=True)
|
|
|
|
built = _capture_config("aws_bedrock", base_config)
|
|
|
|
assert isinstance(built, AWSBedrockConfig)
|
|
assert built.reasoning_effort == "medium"
|
|
assert built.is_reasoning_model is True
|
|
|
|
|
|
def test_base_to_provider_without_reasoning_fields_still_builds():
|
|
# Anthropic config does not accept reasoning_effort/is_reasoning_model;
|
|
# the conversion must not forward unsupported kwargs to it.
|
|
base_config = BaseLlmConfig(model="claude-3-5-sonnet-20240620")
|
|
|
|
built = _capture_config("anthropic", base_config)
|
|
|
|
assert isinstance(built, AnthropicConfig)
|
|
assert built.model == "claude-3-5-sonnet-20240620"
|