Skip to content

Add temperature parameter to LLM.chat()#87

Open
namantiwari2002 wants to merge 1 commit into
Lightning-AI:mainfrom
namantiwari2002:fix/75
Open

Add temperature parameter to LLM.chat()#87
namantiwari2002 wants to merge 1 commit into
Lightning-AI:mainfrom
namantiwari2002:fix/75

Conversation

@namantiwari2002

Copy link
Copy Markdown

Add temperature as an explicit parameter to LLM.chat(), following the same pattern used for reasoning_effort. The parameter is threaded through sync_chat, async_chat, and _model_call before being forwarded to the underlying SDK's model.chat() call.

Valid values are floats in the range [0.0, 2.0]. Passing a value outside this range raises a ValueError immediately, before any network call is made. Passing None (the default) preserves existing behavior.

Fixes #75

How tested

  • Two new unit tests added to tests/test_llm.py:
    • test_llm_chat_temperature — confirms the value is forwarded to the SDK call.
    • test_llm_chat_temperature_validation — confirms out-of-range values raise ValueError.
  • Existing call-site assertions in test_llm_chat, test_model_override, test_fallback_models, and test_empty_response_retries were updated to include temperature=None.
  • Full test suite: PYTHONPATH=src python3 -m pytest tests/test_llm.py -q27 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.

Setting Temperature

1 participant