mirror of
				https://github.com/amithkoujalgi/ollama4j.git
				synced 2025-11-04 10:30:41 +01:00 
			
		
		
		
	Parametrizes the max chat tool call retries for a single chat request
This commit is contained in:
		@@ -59,6 +59,10 @@ public class OllamaAPI {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Setter
 | 
					    @Setter
 | 
				
			||||||
    private boolean verbose = true;
 | 
					    private boolean verbose = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Setter
 | 
				
			||||||
 | 
					    private int maxChatToolCallRetries = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private BasicAuth basicAuth;
 | 
					    private BasicAuth basicAuth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final ToolRegistry toolRegistry = new ToolRegistry();
 | 
					    private final ToolRegistry toolRegistry = new ToolRegistry();
 | 
				
			||||||
@@ -782,7 +786,7 @@ public class OllamaAPI {
 | 
				
			|||||||
        // check if toolCallIsWanted
 | 
					        // check if toolCallIsWanted
 | 
				
			||||||
        List<OllamaChatToolCalls> toolCalls = result.getResponseModel().getMessage().getToolCalls();
 | 
					        List<OllamaChatToolCalls> toolCalls = result.getResponseModel().getMessage().getToolCalls();
 | 
				
			||||||
        int toolCallTries = 0;
 | 
					        int toolCallTries = 0;
 | 
				
			||||||
        while(toolCalls != null && !toolCalls.isEmpty() && toolCallTries <3){
 | 
					        while(toolCalls != null && !toolCalls.isEmpty() && toolCallTries < maxChatToolCallRetries){
 | 
				
			||||||
            for (OllamaChatToolCalls toolCall : toolCalls){
 | 
					            for (OllamaChatToolCalls toolCall : toolCalls){
 | 
				
			||||||
                String toolName = toolCall.getFunction().getName();
 | 
					                String toolName = toolCall.getFunction().getName();
 | 
				
			||||||
                ToolFunction toolFunction = toolRegistry.getToolFunction(toolName);
 | 
					                ToolFunction toolFunction = toolRegistry.getToolFunction(toolName);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user