-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Refactor Options #406
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
Refactor Options #406
Conversation
remove setter
Remove setters from the object, and separate creation and usage to enable safe usage in a multi-threaded environment.
add test code for the modified changes
|
||
/** | ||
* @author Christian Tzolov | ||
*/ | ||
public interface FunctionCallingOptions { | ||
public interface FunctionCallingOptions extends ChatOptions { |
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.
FunctionCallingOptions not extending ChatOptions was intentional in order to provide support finer grained support of what features can be opted into. Also, the code didn't compile after this change, so be sure to do a compilation of the total project before submitting a PR please.
@@ -25,14 +25,8 @@ public interface ChatOptions extends ModelOptions { | |||
|
|||
Float getTemperature(); | |||
|
|||
void setTemperature(Float temperature); |
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.
removing these setters also required to remove the @Override
annotations on all implementing classes. As a result the project didn't compile. Please make sure the changes you make compile before sending a PR.
|
||
Integer newTopK = 222; | ||
|
||
ChatOptions newOptions = ChatOptionsBuilder.builder(options) |
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 sort of copy constructor for the builder is interesting, but please put in a separate PR
assertThat(options.getFunctions().contains(func)); | ||
|
||
// Immutable | ||
options.getFunctionCallbacks().add(cb); |
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.
If we want the created options class to be immutable then we should create a non modifiable collection and throw an exception. We would also need to ensure that all the other options classes behave the same way.
merged only the setter removal as 3938cc8 |
In the original code, Builders and Setters were used concurrently.
This approach could compromise object immutability in multi-threaded environments,
potentially leading to undesirable side effects.
To mitigate this, Setters have been removed to enhance and ensure object immutability.