-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: Enhance Chat Options #2235
base: main
Are you sure you want to change the base?
feat: Enhance Chat Options #2235
Conversation
8c0265c
to
78067d9
Compare
@ThomasVitale @tzolov after the changes in this commit:
In the following scenario using
If we apply the changes from my PR, and use the base class, the resulting request object will be:
This occurs because the following line now calls
The merge function only returns fields from the concrete class, excluding fields from any abstract parent classes:
Therefore, fields defined in the base class are removed:
In contrast, if we use:
all chatOptions are retained. Is this behavior intended? If so we could possibly update the getJsonPropertyValues method as follows to also retain fields from the base classes:
I would appreciate your feedback on this. |
@apappascs thanks for raising this issue! Could you share some details about how you're using |
I see now where the problem arises. All the logic merging options and building the model provider-specific requests objects is tailored to work with concrete objects. So, when we finally merge runtime and default options, they are both of the same concrete type (e.g. The After the changes introduced in this PR, some of those conditions are not true anymore because of the introduction of the abstract class and the move of some of the options upstream. Hence, the errors you mentioned. My suggestion is to keep the current API and not introduce an abstract class. The Moving some of the fields (and the JSON configuration for their naming) up one level introduces an intermediate abstraction, resulting in having to maintain two sets of abstractions: one abstraction for common getters, and one abstraction for common fields, with the risk of additional complexity, fragility, and maintenance cost. For example, in the PR, the I think the |
I like the improvement to ensure the consistent usage of |
@ThomasVitale Thank you for the detailed feedback. I appreciate your careful consideration of the API design and potential long-term maintenance implications. During the refactoring, I noticed that Additionally, the current level of duplicated code (essentially 100% in some areas) presents a significant maintenance challenge. This duplication extends to the tool-related methods (e.g., Furthermore, the I'll put some more thought into this and follow up with a separate comment outlining a revised approach. Hopefully, @tzolov can also provide some input here. |
@apappascs thanks! There's indeed lots of duplication that would be nice to remove, spanning options, models, and apis. |
Key changes include: * **AbstractChatOptions:** Introduced an abstract base class, reducing code duplication. * **DefaultChatOptions:** A concrete implementation of `ChatOptions` built on top of `AbstractChatOptions` * **Equals and HashCode:** Implemented `equals()` and `hashCode()` methods in all ChatOptions classes and the `DefaultChatOptions` class * **Test Updates:** Comprehensive test updates were made across all affected modules to verify the new Builder pattern, copy functionality, and the behavior of the `equals()` and `hashCode()` methods. Signed-off-by: Alexandros Pappas <[email protected]>
Signed-off-by: Alexandros Pappas <[email protected]>
Signed-off-by: Alexandros Pappas <[email protected]>
78067d9
to
1815681
Compare
@ThomasVitale Updated the code to keep only changes for equals, hashCode and tests for now and removed the abstract class as you recommended and we could check if this is an option on another PR. |
Key changes include:
AbstractChatOptions: Introduced an abstract base class, reducing code duplication.DefaultChatOptions: A concrete implementation of
ChatOptions
built on top ofAbstractChatOptions
equals()
andhashCode()
methods in all ChatOptions classes and theDefaultChatOptions
classverify the new Builder pattern, copy functionality, and the behavior of the
equals()
andhashCode()
methods.Locally tested with: