Ensure unique functions in FunctionCallingOptionsBuilder

- Fix issues caused by cf75640c86
- Modify withFunction() to maintain unique function entries using HashSet
This commit is contained in:
Christian Tzolov
2024-10-23 20:39:36 +02:00
parent cf75640c86
commit 9f6ca77bbc

View File

@@ -61,7 +61,9 @@ public class FunctionCallingOptionsBuilder {
public FunctionCallingOptionsBuilder withFunction(String function) {
Assert.notNull(function, "Function must not be null");
this.options.getFunctions().add(function);
var set = new HashSet<>(this.options.getFunctions());
set.add(function);
this.options.setFunctions(set);
return this;
}
@@ -131,7 +133,7 @@ public class FunctionCallingOptionsBuilder {
return this.options;
}
public static class PortableFunctionCallingOptions implements FunctionCallingOptions, ChatOptions {
public static class PortableFunctionCallingOptions implements FunctionCallingOptions {
private List<FunctionCallback> functionCallbacks = new ArrayList<>();