Skip to content

Commit a9086e1

Browse files
committed
Do not log temperature in options if not changed, closes #16
1 parent 29bce51 commit a9086e1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

llm_anthropic.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Optional, List, Union
66

77
DEFAULT_THINKING_TOKENS = 1024
8+
DEFAULT_TEMPERATURE = 1.0
89

910

1011
@llm.hookimpl
@@ -96,7 +97,7 @@ class ClaudeOptions(llm.Options):
9697

9798
temperature: Optional[float] = Field(
9899
description="Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic.",
99-
default=1.0,
100+
default=None,
100101
)
101102

102103
top_p: Optional[float] = Field(
@@ -292,7 +293,11 @@ def build_kwargs(self, prompt, conversation):
292293
if prompt.options.top_p:
293294
kwargs["top_p"] = prompt.options.top_p
294295
else:
295-
kwargs["temperature"] = prompt.options.temperature
296+
kwargs["temperature"] = (
297+
prompt.options.temperature
298+
if prompt.options.temperature is not None
299+
else DEFAULT_TEMPERATURE
300+
)
296301

297302
if prompt.options.top_k:
298303
kwargs["top_k"] = prompt.options.top_k

0 commit comments

Comments
 (0)