Skip to content
Draft
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
28 changes: 28 additions & 0 deletions tests/test_issue_1972.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from unittest.mock import MagicMock, patch

from smolagents.models import LiteLLMModel


def test_issue_1972():
mock_litellm = MagicMock()
mock_response = MagicMock()
mock_response.choices = [MagicMock()]
mock_response.choices[0].message.role = "assistant"
mock_response.choices[0].message.content = "FOO.BAR"
mock_response.choices[0].message.tool_calls = None
mock_response.usage.prompt_tokens = 10
mock_response.usage.completion_tokens = 5
mock_litellm.completion.return_value = mock_response

messages = [
{"role": "system", "content": "When you say anything Start with 'FOO'"},
{"role": "system", "content": "When you say anything End with 'BAR'"},
{"role": "user", "content": "Just say '.'"},
]

with patch("smolagents.models.LiteLLMModel.create_client", return_value=mock_litellm):
model = LiteLLMModel(model_id="gemini/gemini-2.5-flash", api_key="test_api_key")
response = model(messages)

assert response.content == "FOO.BAR"
assert mock_litellm.completion.call_count == 1