Home / Function/ test_explicit_options_dict_preserved() — langchain Function Reference

test_explicit_options_dict_preserved() — langchain Function Reference

Architecture documentation for the test_explicit_options_dict_preserved() function in test_chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  3b93b285_fc87_47ab_f8ed_e7f0f5fa6fdc["test_explicit_options_dict_preserved()"]
  9c4a2438_9884_cbb0_3cf5_de8827531653["test_chat_models.py"]
  3b93b285_fc87_47ab_f8ed_e7f0f5fa6fdc -->|defined in| 9c4a2438_9884_cbb0_3cf5_de8827531653
  style 3b93b285_fc87_47ab_f8ed_e7f0f5fa6fdc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/ollama/tests/unit_tests/test_chat_models.py lines 383–412

def test_explicit_options_dict_preserved() -> None:
    """Test that explicitly provided options dict is preserved and not filtered."""
    response = [
        {
            "model": "test-model",
            "created_at": "2025-01-01T00:00:00.000000000Z",
            "done": True,
            "done_reason": "stop",
            "message": {"role": "assistant", "content": "Hello!"},
        }
    ]

    with patch("langchain_ollama.chat_models.Client") as mock_client_class:
        mock_client = MagicMock()
        mock_client_class.return_value = mock_client
        mock_client.chat.return_value = response

        llm = ChatOllama(model="test-model")
        # Pass explicit options dict, including None values
        llm.invoke(
            [HumanMessage("Hello")],
            options={"temperature": 0.5, "custom_param": None},
        )

        # Get the options dict that was passed to chat
        call_kwargs = mock_client.chat.call_args[1]
        options = call_kwargs.get("options", {})

        # Explicit options should be preserved as-is
        assert options == {"temperature": 0.5, "custom_param": None}

Domain

Subdomains

Frequently Asked Questions

What does test_explicit_options_dict_preserved() do?
test_explicit_options_dict_preserved() is a function in the langchain codebase, defined in libs/partners/ollama/tests/unit_tests/test_chat_models.py.
Where is test_explicit_options_dict_preserved() defined?
test_explicit_options_dict_preserved() is defined in libs/partners/ollama/tests/unit_tests/test_chat_models.py at line 383.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free