fix: strip unsupported params for reasoning models & handle UnboundLocalError in Generator#492
Open
YardonYan wants to merge 1 commit into
Open
fix: strip unsupported params for reasoning models & handle UnboundLocalError in Generator#492YardonYan wants to merge 1 commit into
YardonYan wants to merge 1 commit into
Conversation
…calError in Generator Fixes SylphAI-Inc#481 Bug 1: OpenAI Responses API rejects frequency_penalty, presence_penalty, temperature, and top_p for reasoning models (o1, o3-mini, etc.). Added parameter filtering in OpenAIClient.convert_inputs_to_api_kwargs() when model_type is LLM_REASONING. Bug 2: Generator._get_default_mapping() raised UnboundLocalError when both output.data and output.raw_response were None (e.g. API call failure). Added else branch returning empty mapping and fields. Tests: - test_convert_inputs_to_api_kwargs_reasoning_model_strips_unsupported_params - test_convert_inputs_to_api_kwargs_llm_keeps_all_params - TestGetDefaultMapping (4 test cases)
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.
Fixes #481
Summary
Two bugs fixed for Issue #481 (Quickstart Colab fails with frequency_penalty error on reasoning models):
Bug 1: Reasoning models reject unsupported Chat Completion params
OpenAI Responses API rejects \requency_penalty, \presence_penalty, \ emperature, and \ op_p\ for reasoning models (o1, o3-mini, etc.), causing \BadRequestError.
Fix: Added parameter filtering in \OpenAIClient.convert_inputs_to_api_kwargs()\ — when \model_type == ModelType.LLM_REASONING, these unsupported params are stripped from \inal_model_kwargs\ with a warning log.
Bug 2: \UnboundLocalError\ in \Generator._get_default_mapping()\
When both \output.data\ and \output.raw_response\ were \None\ (e.g. API call failure), the method raised \UnboundLocalError\ because \output_mapping\ and \output_fields\ were never assigned.
Fix: Added an \else\ branch returning empty \output_mapping={}\ and \output_fields=[]\ with a warning log.
Root Cause Analysis (Issue #481)
Tests Added (6 new, all passing)
Files Changed