Skip to content

fix(calibrate_response_mapper): honor output_pattern when set - #1017

Merged
cmgzn merged 1 commit into
mainfrom
pulp/calibrate-output-pattern
Jul 28, 2026
Merged

fix(calibrate_response_mapper): honor output_pattern when set#1017
cmgzn merged 1 commit into
mainfrom
pulp/calibrate-output-pattern

Conversation

@cmgzn

@cmgzn cmgzn commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Problem

CalibrateResponseMapper.parse_output() ignores the output_pattern parameter entirely. The parent class CalibrateQAMapper uses self.output_pattern for regex extraction, but CalibrateResponseMapper overrides parse_output to always return raw_output.strip(), making the parameter a no-op.

Before fix: User sets output_pattern: 'Answer:\\s*(.*)'', gets back full raw text 'Answer: my calibrated response'.

After fix: Regex is applied, correctly extracts 'my calibrated response'.

Fix

When the user provides a custom output_pattern (different from DEFAULT_OUTPUT_PATTERN), apply regex matching. Fall back to the original strip behavior if no custom pattern is set or if regex doesn't match.

Test

mapper = CalibrateResponseMapper(output_pattern=r'Answer:\\s*(.*)')
# Before: parse_output('Answer: foo') → (None, 'Answer: foo')  # BUG
# After:  parse_output('Answer: foo') → (None, 'foo')          # FIXED
# Default behavior (no custom pattern) unchanged

parse_output() previously ignored self.output_pattern entirely,
always returning the raw stripped text. Now applies the regex when
the user provides a custom output_pattern, falling back to the
original strip behavior otherwise.

Pulp-Item: fine_a11f905aa2b4
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@cmgzn
cmgzn merged commit e1c19f9 into main Jul 28, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants