AI rule node: support top K for Google AI Gemini, Google Vertex AI Gemini and Anthropic

This commit is contained in:
Dmytro Skarzhynets 2025-06-27 19:02:44 +03:00
parent afb0259010
commit 72db8f9823
No known key found for this signature in database
GPG Key ID: 2B51652F224037DF
4 changed files with 8 additions and 0 deletions

View File

@ -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();

View File

@ -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> {}

View File

@ -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> {}

View File

@ -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> {}