Fix ToolCallingChatOptions isInternalToolExecutionEnabled
- The ModelOptionsUtils merges the ToolCallingChatOptions with the provider chat options - The underlying beanwrapper implementation expects the boolean option to have the getter method starting with "get" instad of "is" which makes the current `isInternalToolExecutionEnabled` not used by the merge operation at all. To fix this, rename the `isInternalToolExecutionEnabled` method to `getInternalToolExecutionEnabled` and deprecate the existing `isInternalToolExecutionEnabled` method. Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
This commit is contained in:
committed by
Christian Tzolov
parent
257c91ccf2
commit
76a1dbe747
@@ -109,7 +109,7 @@ public class DefaultToolCallingChatOptions implements ToolCallingChatOptions {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Boolean isInternalToolExecutionEnabled() {
|
||||
public Boolean getInternalToolExecutionEnabled() {
|
||||
return this.internalToolExecutionEnabled;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class DefaultToolCallingChatOptions implements ToolCallingChatOptions {
|
||||
@Override
|
||||
@Nullable
|
||||
public Boolean getProxyToolCalls() {
|
||||
return isInternalToolExecutionEnabled() != null ? !isInternalToolExecutionEnabled() : null;
|
||||
return getInternalToolExecutionEnabled() != null ? !getInternalToolExecutionEnabled() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,7 +236,7 @@ public class DefaultToolCallingChatOptions implements ToolCallingChatOptions {
|
||||
options.setToolCallbacks(getToolCallbacks());
|
||||
options.setToolNames(getToolNames());
|
||||
options.setToolContext(getToolContext());
|
||||
options.setInternalToolExecutionEnabled(isInternalToolExecutionEnabled());
|
||||
options.setInternalToolExecutionEnabled(getInternalToolExecutionEnabled());
|
||||
options.setModel(getModel());
|
||||
options.setFrequencyPenalty(getFrequencyPenalty());
|
||||
options.setMaxTokens(getMaxTokens());
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* including tool calling.
|
||||
*
|
||||
* @author Thomas Vitale
|
||||
* @author Ilayaperumal Gopinathan
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface ToolCallingChatOptions extends FunctionCallingOptions {
|
||||
@@ -68,7 +69,17 @@ public interface ToolCallingChatOptions extends FunctionCallingOptions {
|
||||
* the model or if the tools should be executed directly by the caller.
|
||||
*/
|
||||
@Nullable
|
||||
Boolean isInternalToolExecutionEnabled();
|
||||
Boolean getInternalToolExecutionEnabled();
|
||||
|
||||
/**
|
||||
* Whether the {@link ChatModel} is responsible for executing the tools requested by
|
||||
* the model or if the tools should be executed directly by the caller.
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
default Boolean isInternalToolExecutionEnabled() {
|
||||
return getInternalToolExecutionEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the {@link ChatModel} is responsible for executing the tools requested
|
||||
|
||||
@@ -65,8 +65,9 @@ public interface ToolExecutionEligibilityChecker extends Function<ChatResponse,
|
||||
Assert.notNull(chatOptions, "chatOptions cannot be null");
|
||||
boolean internalToolExecutionEnabled;
|
||||
if (chatOptions instanceof ToolCallingChatOptions toolCallingChatOptions
|
||||
&& toolCallingChatOptions.isInternalToolExecutionEnabled() != null) {
|
||||
internalToolExecutionEnabled = Boolean.TRUE.equals(toolCallingChatOptions.isInternalToolExecutionEnabled());
|
||||
&& toolCallingChatOptions.getInternalToolExecutionEnabled() != null) {
|
||||
internalToolExecutionEnabled = Boolean.TRUE
|
||||
.equals(toolCallingChatOptions.getInternalToolExecutionEnabled());
|
||||
}
|
||||
else if (chatOptions instanceof FunctionCallingOptions functionCallingOptions
|
||||
&& functionCallingOptions.getProxyToolCalls() != null) {
|
||||
|
||||
@@ -150,7 +150,7 @@ class DefaultToolCallingChatOptionsTests {
|
||||
assertThat(c.getToolCallbacks()).isEqualTo(original.getToolCallbacks());
|
||||
assertThat(c.getToolNames()).isEqualTo(original.getToolNames());
|
||||
assertThat(c.getToolContext()).isEqualTo(original.getToolContext());
|
||||
assertThat(c.isInternalToolExecutionEnabled()).isEqualTo(original.isInternalToolExecutionEnabled());
|
||||
assertThat(c.getInternalToolExecutionEnabled()).isEqualTo(original.getInternalToolExecutionEnabled());
|
||||
assertThat(c.getModel()).isEqualTo(original.getModel());
|
||||
assertThat(c.getTemperature()).isEqualTo(original.getTemperature());
|
||||
});
|
||||
@@ -195,7 +195,7 @@ class DefaultToolCallingChatOptionsTests {
|
||||
assertThat(o.getToolCallbacks()).containsExactly(callback);
|
||||
assertThat(o.getToolNames()).containsExactly("tool1");
|
||||
assertThat(o.getToolContext()).isEqualTo(context);
|
||||
assertThat(o.isInternalToolExecutionEnabled()).isTrue();
|
||||
assertThat(o.getInternalToolExecutionEnabled()).isTrue();
|
||||
assertThat(o.getModel()).isEqualTo("gpt-4");
|
||||
assertThat(o.getTemperature()).isEqualTo(0.7);
|
||||
assertThat(o.getMaxTokens()).isEqualTo(100);
|
||||
@@ -236,7 +236,7 @@ class DefaultToolCallingChatOptionsTests {
|
||||
assertThat(options.getProxyToolCalls()).isFalse();
|
||||
|
||||
options.setProxyToolCalls(true);
|
||||
assertThat(options.isInternalToolExecutionEnabled()).isFalse();
|
||||
assertThat(options.getInternalToolExecutionEnabled()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user