Skip to content

No way to "unset" parameters when cloning #468

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

Open
mzattera opened this issue May 11, 2025 · 0 comments
Open

No way to "unset" parameters when cloning #468

mzattera opened this issue May 11, 2025 · 0 comments

Comments

@mzattera
Copy link

mzattera commented May 11, 2025

I have created a Params object which stores some desired "default" configuration settings; I want to use it as "template" when creating new API requests, which I can then configure for specific calls. This in principle work except for some parameters, e.g.:

CompletionCreateParams template = CompletionCreateParams.builder().prompt("").maxTokens(500).echo(false).n(1).build()

// Now I want to create a copy of template, to use in a specific setting, changing only some of its parameters.
		
// This works
CompletionCreateParams copy = template.toBuilder().maxTokens(250).build();

// But this doesn't so I cannot say "use default value for max tokens"
copy = template.toBuilder().maxTokens(null).build();

I think for optional parameters builder should always take nullable values (Integer in this case), otherwise is impossible to "unset" a parameter once it has been set. This will be consistent with same parameters returning Optional<> when they are read.

Is there a workaround already I do not see?

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

No branches or pull requests

1 participant