-
Notifications
You must be signed in to change notification settings - Fork 25
add llm pool & judge panel config #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds an LLM configuration subsystem (LLMParametersConfig, LLMDefaultsConfig, LLMProviderConfig, LLMPoolConfig) and judge-panel config (JudgePanelConfig), exposes LLMPoolConfig and JudgePanelConfig in the package API, extends SystemConfig with llm_pool/judge_panel and resolution methods, and adds consolidated unit tests. (≈39 words) Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
🤖 Fix all issues with AI agents
In `@src/lightspeed_evaluation/core/models/system.py`:
- Around line 399-454: LLMProviderConfig.api_key_path is parsed but never
propagated into the resolved LLMConfig, so update the resolved model: add an
api_key_path (and optionally api_base if planned) field to the LLMConfig
dataclass/model and assign provider.api_key_path inside resolve_llm_config (the
code that builds the LLMConfig from LLMProviderConfig); locate
resolve_llm_config and the LLMConfig type and set llm_config.api_key_path =
provider.api_key_path (and llm_config.api_base = provider.api_base if you add
that field) so the API key path is carried forward rather than dropped.
- Around line 570-580: The current validate_enabled_metrics (field_validator on
"enabled_metrics") only checks for ":" presence and allows empty framework or
metric parts; update it to split each metric on ":" (preferably
metric.split(":", 1)), verify there are exactly two non-empty trimmed parts
(framework and metric_name), and raise ValueError if either side is missing or
blank, keeping the existing error message format to indicate the required
"framework:metric_name" structure.
- Around line 645-669: Replace the ValueError used for configuration validation
in get_judge_configs with the project-specific ConfigurationError from
core.system.exceptions: import ConfigurationError (or the exceptions module) at
the top of the file and raise ConfigurationError instead of ValueError in
get_judge_configs; also update the analogous check in get_llm_config to raise
ConfigurationError so both configuration validation failures use the custom
exception type (refer to symbols get_judge_configs, get_llm_config, and
ConfigurationError).
In `@tests/unit/core/models/test_system.py`:
- Around line 338-383: Add unit tests to cover the error branches in
SystemConfig: create tests that call SystemConfig.get_judge_configs() when
judge_panel is set but llm_pool is None and assert it raises ValueError
mentioning "llm_pool"; create a test that calls
SystemConfig.get_llm_config("...") on a SystemConfig with no llm_pool and assert
it raises ValueError mentioning "llm_pool"; and add a test where llm_pool exists
but a judge id in JudgePanelConfig is missing from llm_pool.models and assert
get_judge_configs() raises the appropriate error (or ValueError) for a missing
judge id. Locate and add these tests alongside the existing
TestSystemConfigWithLLMPoolAndJudgePanel methods so they exercise
get_judge_configs and get_llm_config error paths.
- Around line 325-327: Replace the instance construction that uses a type ignore
with a direct pydantic validation call: inside the
pytest.raises(ValidationError) block call
JudgePanelConfig.model_validate({"judges": [{"provider": "openai"}]}) instead of
JudgePanelConfig(judges=[{"provider": "openai"}]) and remove the "# type:
ignore[list-item]" comment so the validation path is exercised without silencing
type checks; this uses the JudgePanelConfig.model_validate method to trigger the
same validation error.
- Around line 156-172: In test_extra_params_and_to_dict, remove the "# type:
ignore[attr-defined]" suppression and assert the extra field via Pydantic's API
instead of attribute access: fetch the dynamic field from the validated model
(e.g., use params.model_dump().get("top_p") or params.model_extra /
params.model_dump(exclude_none=...) as appropriate) and assert its value;
reference LLMParametersConfig, the test function test_extra_params_and_to_dict,
and the params variable when making the change.
- Line 174: The TestLLMProviderConfig class currently silences
"too-few-public-methods"; remove the "# pylint: disable=too-few-public-methods"
and fix the underlying issue by adding an additional test method (e.g., add
test_empty_provider_string or test_invalid_provider_values) inside the same
class so it has multiple public methods, or alternatively merge the existing
test_llm_provider_config method into a neighboring test class (e.g.,
TestSystemConfig) and delete the empty class; update references to the
class/method names (TestLLMProviderConfig, test_llm_provider_config) accordingly
to ensure tests still run and lint passes.
🧹 Nitpick comments (2)
src/lightspeed_evaluation/core/models/system.py (2)
511-517: Consideros.path.joinfor cache directory construction.String concatenation with
"/"isn't portable across platforms, andrstrip("/")won't handle"\\"on Windows. Usingos.path.joinwould be more robust.Suggested fix
- base_cache = self.defaults.cache_dir.rstrip("/") - cache_dir = ( - f"{base_cache}/{cache_suffix}" - if cache_suffix - else f"{base_cache}/{model_id}" - ) + suffix = cache_suffix if cache_suffix else model_id + cache_dir = os.path.join(self.defaults.cache_dir, suffix)
594-622: Consider eager cross-validation ofjudge_panel.judgesagainstllm_pool.models.Currently, if a judge ID doesn't exist in
llm_pool.models, the error surfaces only whenget_judge_configs()is called at runtime. Amodel_validator(mode="after")onSystemConfigcould catch misconfiguration at parse time, providing a better developer experience.Example
`@model_validator`(mode="after") def _validate_judge_panel_references(self) -> "SystemConfig": if self.judge_panel and self.llm_pool: available = set(self.llm_pool.models.keys()) missing = [j for j in self.judge_panel.judges if j not in available] if missing: raise ValueError( f"Judge IDs {missing} not found in llm_pool.models. " f"Available: {sorted(available)}" ) return self
9696f3d to
92bb19c
Compare
|
@coderabbitai help |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/lightspeed_evaluation/core/models/system.py`:
- Around line 694-695: The docstring for the method that validates llm_pool
currently states it raises ValueError but the implementation actually raises
ConfigurationError; update the Raises section to list ConfigurationError
(including its module/class name if you use a custom exception, e.g.,
ConfigurationError) and a short description like "If llm_pool not configured or
model not found" so the docstring matches the actual exception raised by the
method that references llm_pool and ConfigurationError.
🧹 Nitpick comments (1)
src/lightspeed_evaluation/core/models/system.py (1)
506-512:resolve_llm_configraisesValueErrorinstead ofConfigurationError.This is inconsistent with
get_judge_configsandget_llm_configwhich were updated to raiseConfigurationError. Since thisValueErrorpropagates throughget_judge_configsuncaught, callers see mixed exception types for configuration issues.Suggested fix
if model_id not in self.models: - raise ValueError( + raise ConfigurationError( f"Model '{model_id}' not found in llm_pool.models. " f"Available: {list(self.models.keys())}" )As per coding guidelines: "Use custom exceptions from core.system.exceptions module for error handling."
92bb19c to
8aacdca
Compare
VladimirKadlec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks.
LGTM
Description
Type of change
Tools used to create PR
Identify any AI code assistants used in this PR (for transparency and review context)
Related Tickets & Documents
Checklist before requesting a review
Testing
Summary by CodeRabbit
New Features
Tests