Skip to content

Commit 7f9cfac

Browse files
committed
fix(mappers): Update reasoning parameter handling in OpenAI mapping
1 parent 4fe1a65 commit 7f9cfac

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎backend/app/services/llm/mappers.py‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def map_kaapi_to_openai_params(
7070
- instructions → instructions
7171
- knowledge_base_ids → tools[file_search].vector_store_ids
7272
- max_num_results → tools[file_search].max_num_results (fallback default)
73-
- reasoning → reasoning.effort (if reasoning supported by model else suppressed)
73+
- effort → reasoning.effort (if reasoning supported by model else suppressed)
74+
- reasoning → legacy alias for effort, used only when effort is absent
7475
- temperature → temperature (if reasoning not supported by model else suppressed)
7576
7677
Returns:
@@ -83,6 +84,7 @@ def map_kaapi_to_openai_params(
8384

8485
model = kaapi_params.get("model")
8586
reasoning = kaapi_params.get("reasoning")
87+
effort = kaapi_params.get("effort")
8688
temperature = kaapi_params.get("temperature")
8789
instructions = kaapi_params.get("instructions")
8890
knowledge_base_ids = kaapi_params.get("knowledge_base_ids")
@@ -92,21 +94,25 @@ def map_kaapi_to_openai_params(
9294
session=session, provider="openai", model_name=model
9395
)
9496

97+
# 'effort' is the canonical knob; 'reasoning' is a legacy alias kept for
98+
# backward compatibility and only consulted when 'effort' is absent
99+
effort_value = effort if effort is not None else reasoning
100+
95101
# Handle reasoning vs temperature mutual exclusivity
96102
if support_reasoning:
97-
if reasoning is not None:
98-
openai_params["reasoning"] = {"effort": reasoning}
103+
if effort_value is not None:
104+
openai_params["reasoning"] = {"effort": effort_value}
99105

100106
if temperature is not None:
101107
warnings.append(
102108
"Parameter 'temperature' was suppressed because the selected model "
103109
"supports reasoning, and temperature is ignored when reasoning is enabled."
104110
)
105111
else:
106-
if reasoning is not None:
112+
if effort_value is not None:
107113
warnings.append(
108-
"Parameter 'reasoning' was suppressed because the selected model "
109-
"does not support reasoning."
114+
"Parameters 'reasoning'/'effort' were suppressed because the "
115+
"selected model does not support reasoning."
110116
)
111117

112118
if temperature is not None:

0 commit comments

Comments
 (0)