Skip to content

Commit 1fb4635

Browse files
jsonbaileyclaude
andcommitted
fix: use package-manager-agnostic message when provider package is missing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6533b5f commit 1fb4635

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

packages/sdk/server-ai/src/ldai/providers/runner_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,4 @@ def _pkg_exists(package_name: str) -> None:
192192
"""
193193
if util.find_spec(package_name) is None:
194194
pypi_name = _PYPI_PACKAGE_NAMES.get(package_name, package_name)
195-
raise ImportError(f"Package '{pypi_name}' not found. Run: pip install {pypi_name}")
195+
raise ImportError(f"Package '{pypi_name}' not found. Make sure it is installed.")

packages/sdk/server-ai/tests/test_runner_factory.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ def test_raises_import_error_with_pypi_name_for_openai(self):
1616
with pytest.raises(ImportError) as exc_info:
1717
RunnerFactory._pkg_exists('ldai_openai')
1818
assert 'launchdarkly-server-sdk-ai-openai' in str(exc_info.value)
19-
assert 'pip install launchdarkly-server-sdk-ai-openai' in str(exc_info.value)
19+
assert 'pip install' not in str(exc_info.value)
2020

2121
def test_raises_import_error_with_pypi_name_for_langchain(self):
2222
with patch('ldai.providers.runner_factory.util') as mock_util:
2323
mock_util.find_spec.return_value = None
2424
with pytest.raises(ImportError) as exc_info:
2525
RunnerFactory._pkg_exists('ldai_langchain')
2626
assert 'launchdarkly-server-sdk-ai-langchain' in str(exc_info.value)
27-
assert 'pip install launchdarkly-server-sdk-ai-langchain' in str(exc_info.value)
27+
assert 'pip install' not in str(exc_info.value)
2828

2929
def test_raises_import_error_with_module_name_when_no_mapping(self):
3030
"""Unknown module names fall back to the module name itself."""
@@ -74,11 +74,11 @@ def test_warning_includes_pypi_name_for_langchain(self):
7474
assert 'launchdarkly-server-sdk-ai-langchain' in warning_text
7575
assert 'ldai_langchain' not in warning_text
7676

77-
def test_warning_does_not_contain_make_sure_text(self):
78-
"""The old boilerplate text should be replaced by actionable pip install instructions."""
77+
def test_warning_does_not_reference_pip(self):
78+
"""Warning should be package-manager agnostic — no pip install command."""
7979
with patch('ldai.providers.runner_factory.util') as mock_util, \
8080
patch('ldai.providers.runner_factory.log') as mock_log:
8181
mock_util.find_spec.return_value = None
8282
RunnerFactory._get_provider_factory('openai')
8383
warning_text = mock_log.warning.call_args[0][0]
84-
assert 'Make sure the corresponding package is installed' not in warning_text
84+
assert 'pip install' not in warning_text

0 commit comments

Comments
 (0)