Skip to content

Remove the usage of required modifier #239

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ShivangiReja
Copy link
Collaborator

This PR removes the use of the required modifier as it is not necessary. According to the guidelines, the constructor should take the required parameters.

@@ -374,7 +374,7 @@ public class FunctionToolDefinition : ToolDefinition, IJsonModel<FunctionToolDef
public FunctionToolDefinition();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use the required keyword on these if we provide a public default constructor -- that is, if we want to support use like:

Tools =
{
    new FunctionToolDefinition()
    {
        FunctionName = "my_function",
    }
},

Without the keyword, there's no enforcement of the required properties being present.

I thought we'd agreed in the architecture discussion to keep the required property with default constructor support together with the constructor that accepts all required properties.

If we want to remove required, I'd like to understand why but also don't think we can do it without also removing the public default constructor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the default constructor as it aligns better with our established guidelines. According to the guidelines, we should provide public constructors with required parameters instead of relying on property initializers, as this ensures that necessary properties are always set.

Currently, only two models use the required modifier, which is inconsistent with the rest of our models. I think a better approach is to remove the required modifier from these models and provide only public constructors with required parameters. This way, we maintain consistency and follow best practices.

@joseharriaga joseharriaga marked this pull request as draft September 19, 2024 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants