Feature/scaleway glm litellm dispatching#119
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a small, self-contained Python helper module for dispatching LiteLLM completions through Scaleway’s OpenAI-compatible GLM endpoint, with a fallback mechanism to alternate LiteLLM model IDs, plus accompanying documentation and tests.
Changes:
- Added
ScalewayGLMConfig(env-driven config + validation) and message normalization helpers. - Added
scaleway_glm_completion()wrapper anddispatch_with_fallback()retry/fallback logic. - Added a README and a unit test file covering payload construction and fallback behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
litellm_scaleway_dispatching/scaleway_glm_dispatcher.py |
New Scaleway GLM config + LiteLLM completion wrapper + fallback dispatch logic. |
tests/test_scaleway_glm_dispatcher.py |
New unit tests validating normalization, config validation, payload construction, and fallback behavior. |
litellm_scaleway_dispatching/README.md |
Usage and environment-variable documentation, including test-running instructions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for model in fallback_models: | ||
| try: | ||
| return completion_func(messages=messages, model=model, **kwargs) |
| import pytest | ||
|
|
||
| from litellm_scaleway_dispatching.scaleway_glm_dispatcher import ( | ||
| DEFAULT_MODEL, | ||
| ScalewayGLMConfig, | ||
| ScalewayGLMConfigurationError, | ||
| dispatch_with_fallback, | ||
| normalize_messages, | ||
| scaleway_glm_completion, | ||
| ) |
There was a problem hiding this comment.
Rewrote the tests as unittest.TestCase and moved them to scripts/python/tests/test_scaleway_glm_dispatcher.py so they are picked up by the existing CI command (python -m unittest discover -s scripts/python/tests -v). The old pytest file under tests/ has been removed, and the README test instructions have been updated accordingly. All 68 tests pass.
There was a problem hiding this comment.
Addressed in 658cf39. The tests have been rewritten using unittest.TestCase (replacing all pytest.raises with self.assertRaises/self.assertRaisesRegex, monkeypatch.setenv with unittest.mock.patch.dict, and the parametrized error-classification test with individual test methods) and moved to scripts/python/tests/test_scaleway_glm_dispatcher.py. All 68 tests pass via python -m unittest discover -s scripts/python/tests -v.
| ## Run tests | ||
|
|
||
| pip install pytest litellm | ||
| pytest -q tests/test_scaleway_glm_dispatcher.py | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Summary
Validation
--dry-runor-WhatIfSafety