mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-16 12:47:19 +08:00
fix(agent): preserve zero temperature setting (#16897)
### Summary - Preserve an explicitly enabled `temperature=0` in the Agent LLM configuration. - Continue excluding invalid negative temperature values. - Add a focused regression test to the existing Agent LLM test file. Fixes #16683
This commit is contained in:
@@ -70,7 +70,7 @@ class LLMParam(ComponentParamBase):
|
||||
|
||||
if int(self.max_tokens) > 0 and get_attr("maxTokensEnabled"):
|
||||
conf["max_tokens"] = int(self.max_tokens)
|
||||
if float(self.temperature) > 0 and get_attr("temperatureEnabled"):
|
||||
if float(self.temperature) >= 0 and get_attr("temperatureEnabled"):
|
||||
conf["temperature"] = float(self.temperature)
|
||||
if float(self.top_p) > 0 and get_attr("topPEnabled"):
|
||||
conf["top_p"] = float(self.top_p)
|
||||
|
||||
@@ -59,3 +59,13 @@ def test_fit_messages_uses_default_context_when_max_length_zero():
|
||||
)
|
||||
assert err is None
|
||||
assert msg_fit[-1]["content"] == "User query: test"
|
||||
|
||||
|
||||
@pytest.mark.p1
|
||||
def test_gen_conf_includes_zero_temperature_when_enabled():
|
||||
"""Include an explicitly enabled zero temperature in the model configuration."""
|
||||
param = LLMParam()
|
||||
param.temperature = 0
|
||||
param.temperatureEnabled = True
|
||||
|
||||
assert param.gen_conf()["temperature"] == 0
|
||||
|
||||
Reference in New Issue
Block a user