Skip to content

Commit 1c94347

Browse files
authored
Merge pull request #1559 from stanfordnlp/typed_predictors_fixes_v2_5
Improve o1 support in dspy.LM (QoL errors)
2 parents a052ff4 + 1de0db7 commit 1c94347

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dspy/clients/lm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ def __init__(self, model, model_type='chat', temperature=0.0, max_tokens=1000, c
3030
self.kwargs = dict(temperature=temperature, max_tokens=max_tokens, **kwargs)
3131
self.history = []
3232

33-
# Exceptions for O-1 models, which requires a temperature of 1.0.
34-
if "o1-" in model: self.kwargs['temperature'] = 1.0
33+
if "o1-" in model:
34+
assert max_tokens >= 5000 and temperature == 1.0, \
35+
"OpenAI's o1-* models require passing temperature=1.0 and max_tokens >= 5000 to `dspy.LM(...)`"
36+
3537

3638
def __call__(self, prompt=None, messages=None, **kwargs):
3739
# Build the request.

0 commit comments

Comments
 (0)