Skip to content

Commit

Permalink
Update dataclasses.replace calls in DefaultRetryStrategy
Browse files Browse the repository at this point in the history
This pull request addresses issue #111 by updating the `dataclasses.replace` calls to `call_args.model_copy(update={...})` in the `DefaultRetryStrategy` class. This change is necessary because `SpiceCallArgs` has been converted from a dataclass to a Pydantic model. The updates ensure that the retry strategy correctly modifies the `temperature` attribute of `call_args` based on the attempt number.
  • Loading branch information
mentatai[bot] committed Sep 4, 2024
1 parent 2c9bb7b commit b9e2fe0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spice/retry_strategy/default_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def decide(
self, call_args: SpiceCallArgs, attempt_number: int, model_output: str, name: str
) -> tuple[Behavior, SpiceCallArgs, Any, str]:
if attempt_number == 1 and call_args.temperature is not None:
call_args = dataclasses.replace(call_args, temperature=max(0.2, call_args.temperature))
call_args = call_args.model_copy(update={"temperature": max(0.2, call_args.temperature)})
elif attempt_number > 1 and call_args.temperature is not None:
call_args = dataclasses.replace(call_args, temperature=max(0.5, call_args.temperature))
call_args = call_args.model_copy(update={"temperature": max(0.5, call_args.temperature)})

if self.validator and not self.validator(model_output):
if attempt_number < self.retries:
Expand Down

0 comments on commit b9e2fe0

Please sign in to comment.