-
Couldn't load subscription status.
- Fork 2k
-
It's hypothesized that during design, function calls were thought to be a capability only some models possess, so placing them in the model provider layer (i.e., ChatModel) would be more appropriate. However, as model provider products evolve, they all end up supporting function call capabilities (which is indeed the case, as most models in the market now support function calls). This would lead to ChatModel layer implementations being remarkably similar, resulting in code duplication and redundancy.
Perhaps we can discuss a new implementation approach? For example, abstracting a dedicated tool calling component to handle the current tool calling and model recursive calling logic in ChatModel? Welcome to contribute your ideas, thank you.
Context:ChatModel tool call
org.springframework.ai.openai.OpenAiChatModel#internalCall
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse) { ChatCompletionRequest request = createRequest(prompt, false); ChatResponse response = ... if (this.toolExecutionEligibilityPredicate.isToolExecutionRequired(prompt.getOptions(), response)) { var toolExecutionResult = this.toolCallingManager.executeToolCalls(prompt, response); if (toolExecutionResult.returnDirect()) { // Return tool execution result directly to the client. return ChatResponse.builder() .from(response) .generations(ToolExecutionResult.buildGenerations(toolExecutionResult)) .build(); } else { // Send the tool execution result back to the model. return this.internalCall(new Prompt(toolExecutionResult.conversationHistory(), prompt.getOptions()), response); } } return response; }
Beta Was this translation helpful? Give feedback.