Skip to content

Commit e243d42

Browse files
committed
ToolExecutionEligibilityChecker add logical for attempts
Signed-off-by: lambochen <[email protected]>
1 parent 33847aa commit e243d42

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* responses.
2828
*
2929
* @author Christian Tzolov
30+
* @author lambochen
3031
*/
3132
public interface ToolExecutionEligibilityChecker extends Function<ChatResponse, Boolean> {
3233

@@ -43,6 +44,19 @@ default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse
4344
return this.isInternalToolExecutionEnabled(promptOptions) && this.isToolCallResponse(chatResponse);
4445
}
4546

47+
/**
48+
* Determines if tool execution should be performed based on the prompt options and chat response and attempts.
49+
* @param promptOptions The options from the prompt
50+
* @param chatResponse The response from the chat model
51+
* @param attempts The number of attempts to execute the tool
52+
* @return true if tool execution should be performed, false otherwise
53+
*/
54+
default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse chatResponse, int attempts) {
55+
Assert.notNull(promptOptions, "promptOptions cannot be null");
56+
Assert.notNull(chatResponse, "chatResponse cannot be null");
57+
return this.isInternalToolExecutionEnabled(promptOptions, attempts) && this.isToolCallResponse(chatResponse);
58+
}
59+
4660
/**
4761
* Determines if the response is a tool call message response.
4862
* @param chatResponse The response from the chat model call

0 commit comments

Comments
 (0)