Class FunctionCallingHelper
java.lang.Object
org.springframework.ai.chat.model.AbstractToolCallSupport
org.springframework.ai.model.function.FunctionCallingHelper
Helper class that reuses the
AbstractToolCallSupport
to implement the function
call handling logic on the client side. Used when the withProxyToolCalls(true) option
is enabled.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
Helper used to provide only the function definition, without the actual function call implementation. -
Field Summary
Fields inherited from class org.springframework.ai.chat.model.AbstractToolCallSupport
functionCallbackContext, functionCallbackRegister, IS_RUNTIME_CALL
-
Constructor Summary
ConstructorDescriptionFunctionCallingHelper
(FunctionCallbackContext functionCallbackContext, FunctionCallingOptions functionCallingOptions, List<FunctionCallback> toolFunctionCallbacks) -
Method Summary
Modifier and TypeMethodDescriptionbuildToolCallConversation
(List<Message> previousMessages, AssistantMessage assistantMessage, ToolResponseMessage toolResponseMessage) handleToolCalls
(Prompt prompt, ChatResponse response) boolean
isToolCall
(ChatResponse chatResponse, Set<String> toolCallFinishReasons) processCall
(ChatModel chatModel, Prompt prompt, Set<String> finishReasons, Function<AssistantMessage.ToolCall, String> customFunction) reactor.core.publisher.Flux<ChatResponse>
processStream
(ChatModel chatModel, Prompt prompt, Set<String> finishReasons, Function<AssistantMessage.ToolCall, String> customFunction) Methods inherited from class org.springframework.ai.chat.model.AbstractToolCallSupport
executeFunctions, getFunctionCallbackRegister, isProxyToolCalls, isToolCall, resolveFunctionCallbacks, runtimeFunctionCallbackConfigurations
-
Constructor Details
-
FunctionCallingHelper
public FunctionCallingHelper() -
FunctionCallingHelper
public FunctionCallingHelper(FunctionCallbackContext functionCallbackContext, FunctionCallingOptions functionCallingOptions, List<FunctionCallback> toolFunctionCallbacks)
-
-
Method Details
-
isToolCall
- Overrides:
isToolCall
in classAbstractToolCallSupport
-
buildToolCallConversation
public List<Message> buildToolCallConversation(List<Message> previousMessages, AssistantMessage assistantMessage, ToolResponseMessage toolResponseMessage) - Overrides:
buildToolCallConversation
in classAbstractToolCallSupport
-
handleToolCalls
- Overrides:
handleToolCalls
in classAbstractToolCallSupport
-
processStream
public reactor.core.publisher.Flux<ChatResponse> processStream(ChatModel chatModel, Prompt prompt, Set<String> finishReasons, Function<AssistantMessage.ToolCall, String> customFunction) -
processCall
public ChatResponse processCall(ChatModel chatModel, Prompt prompt, Set<String> finishReasons, Function<AssistantMessage.ToolCall, String> customFunction)
-