Bug Description
Summary
OpenAIResponses.__init__() unconditionally forces 'temperature=1.0for any model inO1_MODELS`, siltently discarding whatever value the caller passed in. There isno warning, no log, no raised exception, the value is just lost.
Affected versions
llama-index-llms-openai (responses.py)
Relevant code
llama-index/llms/openai/response.py, inside __init__():
# TODO: Temp forced to 1.0 for o1
if model in O1_MODELS:
temperature = 1.0
This runs before super().__init__(), so the caller's value is overwritten with no indication.
Why this is wrong
The caller has explicitly expressed in tent by passing a temperature value. Silently overriding it violates the priciple of least surprisee. The correct behavior is one of:
- Raise a
ValueError with a clear message explaining the constraint
- Emit a
logging.warning() so the caller at least knows what happened
- Only force
temperature=1.0 when the caller did not explicitly set it
Reproduction
from llama_index.llms.openai import OpenAIResponses
llm = OpenAIResponses(model="o1-mini", temperature=0.5, api_key="sk-...")
print(llm.temperature) # prints 1.0 - caller's 0.5 was silently discarded
Additional context
The #TODO comment in the source is the only ack of this bahavior - it is not documented anywhere in the official docs or the class docstring.
A minimal no-breaking fix you may consider:
if model in O1_MODELS and temperature == DEFAULT_TEMPERATURE:
temperature = 1.0 # only force if caller didn't explicitly set it
Or the stricter correct fix: raise/warn instead of silently overwriting.
Version
0.14.23
Steps to Reproduce
-
Install the package:
pip install llama-index-llms-openai
-
Instantiate OpenAIResponses with an O1 model and a custom temperature:
from llama_index.llms.openai import OpenAIResponses
llm = OpenAIResponses(
model="o1-mini",
temperature=0.5,
api_key="sk-..."
)
print(llm.temperature)
Expected: 0.5
Actual: 1.0 - caller's value was silently discarded
-
Check responses.py init() to confirm the override:
TODO: Temp forced to 1.0 for o1
if model in O1_MODELS:
temperature = 1.0
Relevant Logs/Tracebacks
Bug Description
Summary
OpenAIResponses.__init__()unconditionally forces 'temperature=1.0for any model inO1_MODELS`, siltently discarding whatever value the caller passed in. There isno warning, no log, no raised exception, the value is just lost.Affected versions
llama-index-llms-openai(responses.py)Relevant code
llama-index/llms/openai/response.py, inside__init__():This runs before
super().__init__(), so the caller's value is overwritten with no indication.Why this is wrong
The caller has explicitly expressed in tent by passing a temperature value. Silently overriding it violates the priciple of least surprisee. The correct behavior is one of:
ValueErrorwith a clear message explaining the constraintlogging.warning()so the caller at least knows what happenedtemperature=1.0when the caller did not explicitly set itReproduction
Additional context
The
#TODOcomment in the source is the only ack of this bahavior - it is not documented anywhere in the official docs or the class docstring.A minimal no-breaking fix you may consider:
Or the stricter correct fix: raise/warn instead of silently overwriting.
Version
0.14.23
Steps to Reproduce
Install the package:
pip install llama-index-llms-openai
Instantiate OpenAIResponses with an O1 model and a custom temperature:
from llama_index.llms.openai import OpenAIResponses
llm = OpenAIResponses(
model="o1-mini",
temperature=0.5,
api_key="sk-..."
)
print(llm.temperature)
Expected: 0.5
Actual: 1.0 - caller's value was silently discarded
Check responses.py init() to confirm the override:
TODO: Temp forced to 1.0 for o1
if model in O1_MODELS:
temperature = 1.0
Relevant Logs/Tracebacks