Skip to content

Commit cbfcf20

Browse files
committed
fix failing tests
1 parent 9c10db0 commit cbfcf20

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

nemoguardrails/actions/llm/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async def llm_call(
9494
_setup_llm_call_info(llm, model_name, model_provider)
9595
all_callbacks = _prepare_callbacks(custom_callback_handlers)
9696

97-
if llm_params:
97+
if llm_params and llm is not None:
9898
llm = llm.bind(**llm_params)
9999

100100
if isinstance(prompt, str):

tests/test_embeddings_only_user_messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def test_examples_included_in_prompts_2(colang_2_config):
205205

206206
info = rails.explain()
207207
assert len(info.llm_calls) == 2
208-
assert 'user said "hi"' in info.llm_calls[0].prompt
208+
assert 'user said "Hi"' in info.llm_calls[0].prompt
209209

210210

211211
def test_no_llm_calls_embedding_only(colang_2_config):

tests/test_tool_calling_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, ToolMessage
2020

2121
from nemoguardrails.actions.llm.utils import (
22+
LLMCallException,
2223
_convert_messages_to_langchain_format,
2324
_extract_content,
2425
_store_tool_calls,
@@ -307,6 +308,13 @@ async def test_llm_call_with_llm_params_temperature_max_tokens():
307308
mock_bound_llm.ainvoke.assert_called_once()
308309

309310

311+
@pytest.mark.asyncio
312+
async def test_llm_call_with_none_llm_and_params():
313+
"""Test that llm_call handles None llm gracefully even with params."""
314+
with pytest.raises(LLMCallException):
315+
await llm_call(None, "Test prompt", llm_params={"temperature": 0.5})
316+
317+
310318
def test_generation_response_tool_calls_field():
311319
"""Test that GenerationResponse can store tool calls."""
312320
test_tool_calls = [

0 commit comments

Comments
 (0)