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())
.temperature(modelConfig.temperature())
.topP(modelConfig.topP())
.topK(modelConfig.topK())
.timeout(toDuration(modelConfig.timeoutSeconds()))
.maxRetries(modelConfig.maxRetries())
.build();
@ -149,6 +150,9 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
if (modelConfig.topP() != null) {
generationConfigBuilder.setTopP(modelConfig.topP().floatValue());
}
if (modelConfig.topK() != null) {
generationConfigBuilder.setTopK(modelConfig.topK());
}
var generationConfig = generationConfigBuilder.build();
// construct generative model instance
@ -186,6 +190,7 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
.modelName(modelConfig.modelId())
.temperature(modelConfig.temperature())
.topP(modelConfig.topP())
.topK(modelConfig.topK())
.timeout(toDuration(modelConfig.timeoutSeconds()))
.maxRetries(modelConfig.maxRetries())
.build();

View File

@ -31,6 +31,7 @@ public record AnthropicChatModel(
String modelId,
Double temperature,
Double topP,
Integer topK,
Integer timeoutSeconds,
Integer maxRetries
) implements AiChatModelConfig<AnthropicChatModel.Config> {}

View File

@ -31,6 +31,7 @@ public record GoogleAiGeminiChatModel(
String modelId,
Double temperature,
Double topP,
Integer topK,
Integer timeoutSeconds,
Integer maxRetries
) implements AiChatModelConfig<GoogleAiGeminiChatModel.Config> {}

View File

@ -31,6 +31,7 @@ public record GoogleVertexAiGeminiChatModel(
String modelId,
Double temperature,
Double topP,
Integer topK,
Integer timeoutSeconds,
Integer maxRetries
) implements AiChatModelConfig<GoogleVertexAiGeminiChatModel.Config> {}