Skip to content

Commit 80c2e26

Browse files
committed
rename iterations to toolExecutionIterations
Signed-off-by: lambochen <[email protected]>
1 parent 56fba7c commit 80c2e26

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

spring-ai-model/src/main/java/org/springframework/ai/model/tool/ToolCallingChatOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static boolean isInternalToolExecutionEnabled(ChatOptions chatOptions) {
131131
return internalToolExecutionEnabled;
132132
}
133133

134-
static boolean isInternalToolExecutionEnabled(ChatOptions chatOptions, int iterations) {
134+
static boolean isInternalToolExecutionEnabled(ChatOptions chatOptions, int toolExecutionIterations) {
135135
boolean isInternalToolExecutionEnabled = isInternalToolExecutionEnabled(chatOptions);
136136
if (!isInternalToolExecutionEnabled) {
137137
return false;
@@ -140,7 +140,7 @@ static boolean isInternalToolExecutionEnabled(ChatOptions chatOptions, int itera
140140
if (chatOptions instanceof ToolCallingChatOptions toolCallingChatOptions
141141
&& toolCallingChatOptions.getInternalToolExecutionMaxIterations() != null) {
142142
int maxIterations = toolCallingChatOptions.getInternalToolExecutionMaxIterations();
143-
return iterations <= maxIterations;
143+
return toolExecutionIterations <= maxIterations;
144144
}
145145

146146
return DEFAULT_TOOL_EXECUTION_ENABLED;

spring-ai-model/src/main/java/org/springframework/ai/model/tool/ToolExecutionEligibilityChecker.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,19 @@ default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse
4646

4747
/**
4848
* Determines if tool execution should be performed based on the prompt options and
49-
* chat response and attempts.
49+
* chat response and toolExecutionIterations.
5050
* @param promptOptions The options from the prompt
5151
* @param chatResponse The response from the chat model
52-
* @param attempts The number of attempts to execute the tool
52+
* @param toolExecutionIterations The number of toolExecutionIterations to execute the
53+
* tool
5354
* @return true if tool execution should be performed, false otherwise
5455
*/
55-
default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse chatResponse, int attempts) {
56+
default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse chatResponse,
57+
int toolExecutionIterations) {
5658
Assert.notNull(promptOptions, "promptOptions cannot be null");
5759
Assert.notNull(chatResponse, "chatResponse cannot be null");
58-
return this.isInternalToolExecutionEnabled(promptOptions, attempts) && this.isToolCallResponse(chatResponse);
60+
return this.isInternalToolExecutionEnabled(promptOptions, toolExecutionIterations)
61+
&& this.isToolCallResponse(chatResponse);
5962
}
6063

6164
/**
@@ -92,19 +95,20 @@ default boolean isInternalToolExecutionEnabled(ChatOptions chatOptions) {
9295
/**
9396
* Determines if tool execution should be performed by the Spring AI or by the client.
9497
* @param chatOptions The options from the chat
95-
* @param attempts The number of attempts to execute the tool
98+
* @param toolExecutionIterations The number of toolExecutionIterations to execute the
99+
* tool
96100
* @return true if tool execution should be performed by Spring AI, false if it should
97101
* be performed by the client
98102
*/
99-
default boolean isInternalToolExecutionEnabled(ChatOptions chatOptions, int attempts) {
103+
default boolean isInternalToolExecutionEnabled(ChatOptions chatOptions, int toolExecutionIterations) {
100104
boolean internalToolExecutionEnabled = isInternalToolExecutionEnabled(chatOptions);
101105
if (!internalToolExecutionEnabled) {
102106
return internalToolExecutionEnabled;
103107
}
104108

105109
if (chatOptions instanceof ToolCallingChatOptions toolCallingChatOptions) {
106110
return toolCallingChatOptions.getInternalToolExecutionMaxIterations() == null
107-
|| attempts <= toolCallingChatOptions.getInternalToolExecutionMaxIterations();
111+
|| toolExecutionIterations <= toolCallingChatOptions.getInternalToolExecutionMaxIterations();
108112
}
109113
return internalToolExecutionEnabled;
110114
}

spring-ai-model/src/main/java/org/springframework/ai/model/tool/ToolExecutionEligibilityPredicate.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,24 @@ default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse
4545

4646
/**
4747
* Determines if tool execution should be performed based on the prompt options and
48-
* chat response and the number of attempts.
48+
* chat response and the number of toolExecutionIterations.
4949
* @param promptOptions The options from the prompt
5050
* @param chatResponse The response from the chat model
51-
* @param attempts The number of attempts
51+
* @param toolExecutionIterations The number of toolExecutionIterations
5252
* @return true if tool execution should be performed, false otherwise
5353
* @see ToolCallingChatOptions#getInternalToolExecutionMaxIterations()
5454
* @see #isToolExecutionRequired(ChatOptions, ChatResponse)
5555
*/
56-
default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse chatResponse, int attempts) {
56+
default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse chatResponse,
57+
int toolExecutionIterations) {
5758
boolean isToolExecutionRequired = isToolExecutionRequired(promptOptions, chatResponse);
5859
if (!isToolExecutionRequired) {
5960
return isToolExecutionRequired;
6061
}
6162

6263
if (promptOptions instanceof ToolCallingChatOptions toolCallingChatOptions) {
6364
return toolCallingChatOptions.getInternalToolExecutionMaxIterations() == null
64-
|| attempts <= toolCallingChatOptions.getInternalToolExecutionMaxIterations();
65+
|| toolExecutionIterations <= toolCallingChatOptions.getInternalToolExecutionMaxIterations();
6566
}
6667
return isToolExecutionRequired;
6768
}

0 commit comments

Comments
 (0)