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
Nested ClassesModifier and TypeClassDescriptionstatic final recordHelper 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
ConstructorsConstructorDescriptionFunctionCallingHelper(FunctionCallbackContext functionCallbackContext, FunctionCallingOptions functionCallingOptions, List<FunctionCallback> toolFunctionCallbacks) -
Method Summary
Modifier and TypeMethodDescriptionbuildToolCallConversation(List<Message> previousMessages, AssistantMessage assistantMessage, ToolResponseMessage toolResponseMessage) handleToolCalls(Prompt prompt, ChatResponse response) booleanisToolCall(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:
isToolCallin classAbstractToolCallSupport
-
buildToolCallConversation
public List<Message> buildToolCallConversation(List<Message> previousMessages, AssistantMessage assistantMessage, ToolResponseMessage toolResponseMessage) - Overrides:
buildToolCallConversationin classAbstractToolCallSupport
-
handleToolCalls
- Overrides:
handleToolCallsin 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)
-