-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update dataclasses.replace calls in DefaultRetryStrategy #112
Changes from 4 commits
b9e2fe0
31be854
0cdea61
f139c96
6e6d7f1
8572625
81e4434
f44adfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,3 @@ | ||||||
import dataclasses | ||||||
from typing import Any, Callable, Optional | ||||||
|
||||||
from spice.call_args import SpiceCallArgs | ||||||
|
@@ -17,9 +16,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: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It's a good practice to provide a default value when using |
||||||
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)}) | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Similar to the previous comment, it's safer to provide a default value when |
||||||
if self.validator and not self.validator(model_output): | ||||||
if attempt_number < self.retries: | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still a dataclass, so shouldn't be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I apologize for the confusion. The
Model
class is indeed still a dataclass. The change fromdataclasses.replace
tomodel_copy
was only necessary for theSpiceCallArgs
class, which has been converted to a Pydantic model. I'll update the PR to keep theModel
class as a dataclass and only change theSpiceCallArgs
related code.