Scorer composition (PR C): roll pure-composition API out to remaining LLM scorers (3/3)#2157
Open
romanlutz wants to merge 1 commit into
Open
Conversation
Migrate the remaining LLM-based scorers off the transitional Scorer._score_value_with_llm_async forwarder to the pure v1.0 composition API and delete the base forwarder. Each scorer now stores chat_target + system_prompt + response_handler and calls _run_llm_scoring_async directly. Scorers migrated: - SelfAskQuestionAnswerScorer - SelfAskRefusalScorer - SelfAskCategoryScorer - SelfAskGeneralTrueFalseScorer - SelfAskScaleScorer - SelfAskLikertScorer - SelfAskGeneralFloatScaleScorer - InsecureCodeScorer Float-scale scorers bake numeric_value=True into the default JsonSchemaResponseHandler; identifiers read response_handler.response_schema. Preset construction moves to from_* factories (from_scale_arguments, from_likert_scale, from_content_classifier, from_question) with module-level render_*_system_prompt and load_scale_arguments helpers. Also migrate first-party consumers off the removed legacy constructors: crescendo, tree_of_attacks, fairness_bias (docstring example), fuzzer, and the scorer initializer registrations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Final PR (3/3) of the scorer-architecture refactor ("Option 5 — scorer-owned composition"), following #2125 (ResponseHandler + internal round-trip helper) and #2146 (TrueFalse pure-composition API +
CallableResponseHandler), both now merged tomain.This rolls the pure v1.0 composition API out to the remaining LLM-based scorers and removes the last transitional forwarder. Each migrated scorer now stores
chat_target+system_prompt+ aresponse_handlerand calls the internal_run_llm_scoring_async(...)helper directly, instead of the baseScorer._score_value_with_llm_asyncforwarder (now deleted).Scorers migrated
SelfAskQuestionAnswerScorerSelfAskRefusalScorerSelfAskCategoryScorerSelfAskGeneralTrueFalseScorerSelfAskScaleScorerSelfAskLikertScorerSelfAskGeneralFloatScaleScorerInsecureCodeScorerDetails
numeric_value=Trueinto the defaultJsonSchemaResponseHandler; the schema is injected into the default handler only (a caller-supplied handler owns its own contract). Identifiers readresponse_handler.response_schema.from_*factories (from_scale_arguments,from_likert_scale,from_content_classifier,from_question) with module-levelrender_*_system_promptandload_scale_argumentshelpers mirroring the TrueFalse precedent from Scorer composition (PR B): TrueFalse pure-composition API + CallableResponseHandler #2146.Scorer._score_value_with_llm_asyncforwarder from the base class.crescendo,tree_of_attacks,fairness_bias(docstring example),fuzzer, and the scorer initializer registrations.Breaking changes (v1.0)
Legacy scorer constructors (e.g.
SelfAskScaleScorer(scale_arguments_path=...),SelfAskLikertScorer(likert_scale=...),SelfAskCategoryScorer(content_classifier_path=...),SelfAskRefusalScorer(refusal_system_prompt_path=...)) are replaced by the composition__init__plusfrom_*factories. This is an intentional v1.0 breaking change; no deprecation shims remain.Testing
tests/unit/score: 1311 passed, 16 skippedtests/unit/executor+tests/unit/setup(touched consumers): 1249 passed, 22 skippedruff check,ruff format --check,ty check pyrit: clean