mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
* New `reasoning` (bool) param to support toggling [Ollama thinking](https://ollama.com/blog/thinking) (#31573, #31700). If `reasoning=True`, Ollama's `thinking` content will be placed in the model responses' `additional_kwargs.reasoning_content`. * Supported by: * ChatOllama (class level, invocation level TODO) * OllamaLLM (TODO) * Added tests to ensure streaming tool calls is successful (#29129) * Refactored tests that relied on `extract_reasoning()` * Myriad docs additions and consistency/typo fixes * Improved type safety in some spots Closes #29129 Addresses #31573 and #31700 Supersedes #31701
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""Test embedding model integration."""
|
|
|
|
from typing import Any
|
|
from unittest.mock import patch
|
|
|
|
from langchain_ollama.embeddings import OllamaEmbeddings
|
|
|
|
MODEL_NAME = "llama3.1"
|
|
|
|
|
|
def test_initialization() -> None:
|
|
"""Test embedding model initialization."""
|
|
OllamaEmbeddings(model=MODEL_NAME, keep_alive=1)
|
|
|
|
|
|
@patch("langchain_ollama.embeddings.validate_model")
|
|
def test_validate_model_on_init(mock_validate_model: Any) -> None:
|
|
"""Test that the model is validated on initialization when requested."""
|
|
# Test that validate_model is called when validate_model_on_init=True
|
|
OllamaEmbeddings(model=MODEL_NAME, validate_model_on_init=True)
|
|
mock_validate_model.assert_called_once()
|
|
mock_validate_model.reset_mock()
|
|
|
|
# Test that validate_model is NOT called when validate_model_on_init=False
|
|
OllamaEmbeddings(model=MODEL_NAME, validate_model_on_init=False)
|
|
mock_validate_model.assert_not_called()
|
|
|
|
# Test that validate_model is NOT called by default
|
|
OllamaEmbeddings(model=MODEL_NAME)
|
|
mock_validate_model.assert_not_called()
|