AI rule node: support top K for Google AI Gemini, Google Vertex AI Gemini and Anthropic
This commit is contained in:
		
							parent
							
								
									afb0259010
								
							
						
					
					
						commit
						72db8f9823
					
				@ -87,6 +87,7 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
 | 
				
			|||||||
                .modelName(modelConfig.modelId())
 | 
					                .modelName(modelConfig.modelId())
 | 
				
			||||||
                .temperature(modelConfig.temperature())
 | 
					                .temperature(modelConfig.temperature())
 | 
				
			||||||
                .topP(modelConfig.topP())
 | 
					                .topP(modelConfig.topP())
 | 
				
			||||||
 | 
					                .topK(modelConfig.topK())
 | 
				
			||||||
                .timeout(toDuration(modelConfig.timeoutSeconds()))
 | 
					                .timeout(toDuration(modelConfig.timeoutSeconds()))
 | 
				
			||||||
                .maxRetries(modelConfig.maxRetries())
 | 
					                .maxRetries(modelConfig.maxRetries())
 | 
				
			||||||
                .build();
 | 
					                .build();
 | 
				
			||||||
@ -149,6 +150,9 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
 | 
				
			|||||||
        if (modelConfig.topP() != null) {
 | 
					        if (modelConfig.topP() != null) {
 | 
				
			||||||
            generationConfigBuilder.setTopP(modelConfig.topP().floatValue());
 | 
					            generationConfigBuilder.setTopP(modelConfig.topP().floatValue());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (modelConfig.topK() != null) {
 | 
				
			||||||
 | 
					            generationConfigBuilder.setTopK(modelConfig.topK());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        var generationConfig = generationConfigBuilder.build();
 | 
					        var generationConfig = generationConfigBuilder.build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // construct generative model instance
 | 
					        // construct generative model instance
 | 
				
			||||||
@ -186,6 +190,7 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
 | 
				
			|||||||
                .modelName(modelConfig.modelId())
 | 
					                .modelName(modelConfig.modelId())
 | 
				
			||||||
                .temperature(modelConfig.temperature())
 | 
					                .temperature(modelConfig.temperature())
 | 
				
			||||||
                .topP(modelConfig.topP())
 | 
					                .topP(modelConfig.topP())
 | 
				
			||||||
 | 
					                .topK(modelConfig.topK())
 | 
				
			||||||
                .timeout(toDuration(modelConfig.timeoutSeconds()))
 | 
					                .timeout(toDuration(modelConfig.timeoutSeconds()))
 | 
				
			||||||
                .maxRetries(modelConfig.maxRetries())
 | 
					                .maxRetries(modelConfig.maxRetries())
 | 
				
			||||||
                .build();
 | 
					                .build();
 | 
				
			||||||
 | 
				
			|||||||
@ -31,6 +31,7 @@ public record AnthropicChatModel(
 | 
				
			|||||||
            String modelId,
 | 
					            String modelId,
 | 
				
			||||||
            Double temperature,
 | 
					            Double temperature,
 | 
				
			||||||
            Double topP,
 | 
					            Double topP,
 | 
				
			||||||
 | 
					            Integer topK,
 | 
				
			||||||
            Integer timeoutSeconds,
 | 
					            Integer timeoutSeconds,
 | 
				
			||||||
            Integer maxRetries
 | 
					            Integer maxRetries
 | 
				
			||||||
    ) implements AiChatModelConfig<AnthropicChatModel.Config> {}
 | 
					    ) implements AiChatModelConfig<AnthropicChatModel.Config> {}
 | 
				
			||||||
 | 
				
			|||||||
@ -31,6 +31,7 @@ public record GoogleAiGeminiChatModel(
 | 
				
			|||||||
            String modelId,
 | 
					            String modelId,
 | 
				
			||||||
            Double temperature,
 | 
					            Double temperature,
 | 
				
			||||||
            Double topP,
 | 
					            Double topP,
 | 
				
			||||||
 | 
					            Integer topK,
 | 
				
			||||||
            Integer timeoutSeconds,
 | 
					            Integer timeoutSeconds,
 | 
				
			||||||
            Integer maxRetries
 | 
					            Integer maxRetries
 | 
				
			||||||
    ) implements AiChatModelConfig<GoogleAiGeminiChatModel.Config> {}
 | 
					    ) implements AiChatModelConfig<GoogleAiGeminiChatModel.Config> {}
 | 
				
			||||||
 | 
				
			|||||||
@ -31,6 +31,7 @@ public record GoogleVertexAiGeminiChatModel(
 | 
				
			|||||||
            String modelId,
 | 
					            String modelId,
 | 
				
			||||||
            Double temperature,
 | 
					            Double temperature,
 | 
				
			||||||
            Double topP,
 | 
					            Double topP,
 | 
				
			||||||
 | 
					            Integer topK,
 | 
				
			||||||
            Integer timeoutSeconds,
 | 
					            Integer timeoutSeconds,
 | 
				
			||||||
            Integer maxRetries
 | 
					            Integer maxRetries
 | 
				
			||||||
    ) implements AiChatModelConfig<GoogleVertexAiGeminiChatModel.Config> {}
 | 
					    ) implements AiChatModelConfig<GoogleVertexAiGeminiChatModel.Config> {}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user