AI rule node: add stop sequences for all providers
This commit is contained in:
parent
d81d41fd7b
commit
0960b4b179
@ -64,6 +64,7 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
|
|||||||
.frequencyPenalty(modelConfig.frequencyPenalty())
|
.frequencyPenalty(modelConfig.frequencyPenalty())
|
||||||
.presencePenalty(modelConfig.presencePenalty())
|
.presencePenalty(modelConfig.presencePenalty())
|
||||||
.maxTokens(modelConfig.maxOutputTokens())
|
.maxTokens(modelConfig.maxOutputTokens())
|
||||||
|
.stop(modelConfig.stopSequences())
|
||||||
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
||||||
.maxRetries(modelConfig.maxRetries())
|
.maxRetries(modelConfig.maxRetries())
|
||||||
.build();
|
.build();
|
||||||
@ -80,6 +81,7 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
|
|||||||
.frequencyPenalty(modelConfig.frequencyPenalty())
|
.frequencyPenalty(modelConfig.frequencyPenalty())
|
||||||
.presencePenalty(modelConfig.presencePenalty())
|
.presencePenalty(modelConfig.presencePenalty())
|
||||||
.maxTokens(modelConfig.maxOutputTokens())
|
.maxTokens(modelConfig.maxOutputTokens())
|
||||||
|
.stop(modelConfig.stopSequences())
|
||||||
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
||||||
.maxRetries(modelConfig.maxRetries())
|
.maxRetries(modelConfig.maxRetries())
|
||||||
.build();
|
.build();
|
||||||
@ -97,6 +99,7 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
|
|||||||
.frequencyPenalty(modelConfig.frequencyPenalty())
|
.frequencyPenalty(modelConfig.frequencyPenalty())
|
||||||
.presencePenalty(modelConfig.presencePenalty())
|
.presencePenalty(modelConfig.presencePenalty())
|
||||||
.maxOutputTokens(modelConfig.maxOutputTokens())
|
.maxOutputTokens(modelConfig.maxOutputTokens())
|
||||||
|
.stopSequences(modelConfig.stopSequences())
|
||||||
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
||||||
.maxRetries(modelConfig.maxRetries())
|
.maxRetries(modelConfig.maxRetries())
|
||||||
.build();
|
.build();
|
||||||
@ -171,6 +174,9 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
|
|||||||
if (modelConfig.maxOutputTokens() != null) {
|
if (modelConfig.maxOutputTokens() != null) {
|
||||||
generationConfigBuilder.setMaxOutputTokens(modelConfig.maxOutputTokens());
|
generationConfigBuilder.setMaxOutputTokens(modelConfig.maxOutputTokens());
|
||||||
}
|
}
|
||||||
|
if (modelConfig.stopSequences() != null) {
|
||||||
|
generationConfigBuilder.addAllStopSequences(modelConfig.stopSequences());
|
||||||
|
}
|
||||||
var generationConfig = generationConfigBuilder.build();
|
var generationConfig = generationConfigBuilder.build();
|
||||||
|
|
||||||
// construct generative model instance
|
// construct generative model instance
|
||||||
@ -198,6 +204,7 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
|
|||||||
.frequencyPenalty(modelConfig.frequencyPenalty())
|
.frequencyPenalty(modelConfig.frequencyPenalty())
|
||||||
.presencePenalty(modelConfig.presencePenalty())
|
.presencePenalty(modelConfig.presencePenalty())
|
||||||
.maxTokens(modelConfig.maxOutputTokens())
|
.maxTokens(modelConfig.maxOutputTokens())
|
||||||
|
.stopSequences(modelConfig.stopSequences())
|
||||||
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
||||||
.maxRetries(modelConfig.maxRetries())
|
.maxRetries(modelConfig.maxRetries())
|
||||||
.build();
|
.build();
|
||||||
@ -213,6 +220,7 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
|
|||||||
.topP(modelConfig.topP())
|
.topP(modelConfig.topP())
|
||||||
.topK(modelConfig.topK())
|
.topK(modelConfig.topK())
|
||||||
.maxTokens(modelConfig.maxOutputTokens())
|
.maxTokens(modelConfig.maxOutputTokens())
|
||||||
|
.stopSequences(modelConfig.stopSequences())
|
||||||
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
||||||
.maxRetries(modelConfig.maxRetries())
|
.maxRetries(modelConfig.maxRetries())
|
||||||
.build();
|
.build();
|
||||||
@ -236,6 +244,7 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
|
|||||||
.temperature(modelConfig.temperature())
|
.temperature(modelConfig.temperature())
|
||||||
.topP(modelConfig.topP())
|
.topP(modelConfig.topP())
|
||||||
.maxOutputTokens(modelConfig.maxOutputTokens())
|
.maxOutputTokens(modelConfig.maxOutputTokens())
|
||||||
|
.stopSequences(modelConfig.stopSequences())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return BedrockChatModel.builder()
|
return BedrockChatModel.builder()
|
||||||
@ -258,6 +267,7 @@ class Langchain4jChatModelConfigurerImpl implements Langchain4jChatModelConfigur
|
|||||||
.frequencyPenalty(modelConfig.frequencyPenalty())
|
.frequencyPenalty(modelConfig.frequencyPenalty())
|
||||||
.presencePenalty(modelConfig.presencePenalty())
|
.presencePenalty(modelConfig.presencePenalty())
|
||||||
.maxTokens(modelConfig.maxOutputTokens())
|
.maxTokens(modelConfig.maxOutputTokens())
|
||||||
|
.stop(modelConfig.stopSequences())
|
||||||
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
.timeout(toDuration(modelConfig.timeoutSeconds()))
|
||||||
.maxRetries(modelConfig.maxRetries())
|
.maxRetries(modelConfig.maxRetries())
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import lombok.With;
|
|||||||
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
||||||
import org.thingsboard.server.common.data.ai.provider.AmazonBedrockProviderConfig;
|
import org.thingsboard.server.common.data.ai.provider.AmazonBedrockProviderConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public record AmazonBedrockChatModel(
|
public record AmazonBedrockChatModel(
|
||||||
AiModelType modelType,
|
AiModelType modelType,
|
||||||
AmazonBedrockProviderConfig providerConfig,
|
AmazonBedrockProviderConfig providerConfig,
|
||||||
@ -32,6 +34,7 @@ public record AmazonBedrockChatModel(
|
|||||||
Double temperature,
|
Double temperature,
|
||||||
Double topP,
|
Double topP,
|
||||||
Integer maxOutputTokens,
|
Integer maxOutputTokens,
|
||||||
|
List<String> stopSequences,
|
||||||
Integer timeoutSeconds,
|
Integer timeoutSeconds,
|
||||||
Integer maxRetries
|
Integer maxRetries
|
||||||
) implements AiChatModelConfig<AmazonBedrockChatModel.Config> {}
|
) implements AiChatModelConfig<AmazonBedrockChatModel.Config> {}
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import lombok.With;
|
|||||||
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
||||||
import org.thingsboard.server.common.data.ai.provider.AnthropicProviderConfig;
|
import org.thingsboard.server.common.data.ai.provider.AnthropicProviderConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public record AnthropicChatModel(
|
public record AnthropicChatModel(
|
||||||
AiModelType modelType,
|
AiModelType modelType,
|
||||||
AnthropicProviderConfig providerConfig,
|
AnthropicProviderConfig providerConfig,
|
||||||
@ -33,6 +35,7 @@ public record AnthropicChatModel(
|
|||||||
Double topP,
|
Double topP,
|
||||||
Integer topK,
|
Integer topK,
|
||||||
Integer maxOutputTokens,
|
Integer maxOutputTokens,
|
||||||
|
List<String> stopSequences,
|
||||||
Integer timeoutSeconds,
|
Integer timeoutSeconds,
|
||||||
Integer maxRetries
|
Integer maxRetries
|
||||||
) implements AiChatModelConfig<AnthropicChatModel.Config> {}
|
) implements AiChatModelConfig<AnthropicChatModel.Config> {}
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import lombok.With;
|
|||||||
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
||||||
import org.thingsboard.server.common.data.ai.provider.AzureOpenAiProviderConfig;
|
import org.thingsboard.server.common.data.ai.provider.AzureOpenAiProviderConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public record AzureOpenAiChatModel(
|
public record AzureOpenAiChatModel(
|
||||||
AiModelType modelType,
|
AiModelType modelType,
|
||||||
AzureOpenAiProviderConfig providerConfig,
|
AzureOpenAiProviderConfig providerConfig,
|
||||||
@ -34,6 +36,7 @@ public record AzureOpenAiChatModel(
|
|||||||
Double frequencyPenalty,
|
Double frequencyPenalty,
|
||||||
Double presencePenalty,
|
Double presencePenalty,
|
||||||
Integer maxOutputTokens,
|
Integer maxOutputTokens,
|
||||||
|
List<String> stopSequences,
|
||||||
Integer timeoutSeconds,
|
Integer timeoutSeconds,
|
||||||
Integer maxRetries
|
Integer maxRetries
|
||||||
) implements AiChatModelConfig<AzureOpenAiChatModel.Config> {}
|
) implements AiChatModelConfig<AzureOpenAiChatModel.Config> {}
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import lombok.With;
|
|||||||
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
||||||
import org.thingsboard.server.common.data.ai.provider.GithubModelsProviderConfig;
|
import org.thingsboard.server.common.data.ai.provider.GithubModelsProviderConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public record GitHubModelsChatModel(
|
public record GitHubModelsChatModel(
|
||||||
AiModelType modelType,
|
AiModelType modelType,
|
||||||
GithubModelsProviderConfig providerConfig,
|
GithubModelsProviderConfig providerConfig,
|
||||||
@ -34,6 +36,7 @@ public record GitHubModelsChatModel(
|
|||||||
Double frequencyPenalty,
|
Double frequencyPenalty,
|
||||||
Double presencePenalty,
|
Double presencePenalty,
|
||||||
Integer maxOutputTokens,
|
Integer maxOutputTokens,
|
||||||
|
List<String> stopSequences,
|
||||||
Integer timeoutSeconds,
|
Integer timeoutSeconds,
|
||||||
Integer maxRetries
|
Integer maxRetries
|
||||||
) implements AiChatModelConfig<GitHubModelsChatModel.Config> {}
|
) implements AiChatModelConfig<GitHubModelsChatModel.Config> {}
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import lombok.With;
|
|||||||
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
||||||
import org.thingsboard.server.common.data.ai.provider.GoogleAiGeminiProviderConfig;
|
import org.thingsboard.server.common.data.ai.provider.GoogleAiGeminiProviderConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public record GoogleAiGeminiChatModel(
|
public record GoogleAiGeminiChatModel(
|
||||||
AiModelType modelType,
|
AiModelType modelType,
|
||||||
GoogleAiGeminiProviderConfig providerConfig,
|
GoogleAiGeminiProviderConfig providerConfig,
|
||||||
@ -35,6 +37,7 @@ public record GoogleAiGeminiChatModel(
|
|||||||
Double frequencyPenalty,
|
Double frequencyPenalty,
|
||||||
Double presencePenalty,
|
Double presencePenalty,
|
||||||
Integer maxOutputTokens,
|
Integer maxOutputTokens,
|
||||||
|
List<String> stopSequences,
|
||||||
Integer timeoutSeconds,
|
Integer timeoutSeconds,
|
||||||
Integer maxRetries
|
Integer maxRetries
|
||||||
) implements AiChatModelConfig<GoogleAiGeminiChatModel.Config> {}
|
) implements AiChatModelConfig<GoogleAiGeminiChatModel.Config> {}
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import lombok.With;
|
|||||||
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
||||||
import org.thingsboard.server.common.data.ai.provider.GoogleVertexAiGeminiProviderConfig;
|
import org.thingsboard.server.common.data.ai.provider.GoogleVertexAiGeminiProviderConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public record GoogleVertexAiGeminiChatModel(
|
public record GoogleVertexAiGeminiChatModel(
|
||||||
AiModelType modelType,
|
AiModelType modelType,
|
||||||
GoogleVertexAiGeminiProviderConfig providerConfig,
|
GoogleVertexAiGeminiProviderConfig providerConfig,
|
||||||
@ -35,6 +37,7 @@ public record GoogleVertexAiGeminiChatModel(
|
|||||||
Double frequencyPenalty,
|
Double frequencyPenalty,
|
||||||
Double presencePenalty,
|
Double presencePenalty,
|
||||||
Integer maxOutputTokens,
|
Integer maxOutputTokens,
|
||||||
|
List<String> stopSequences,
|
||||||
Integer timeoutSeconds,
|
Integer timeoutSeconds,
|
||||||
Integer maxRetries
|
Integer maxRetries
|
||||||
) implements AiChatModelConfig<GoogleVertexAiGeminiChatModel.Config> {}
|
) implements AiChatModelConfig<GoogleVertexAiGeminiChatModel.Config> {}
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import lombok.With;
|
|||||||
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
||||||
import org.thingsboard.server.common.data.ai.provider.MistralAiProviderConfig;
|
import org.thingsboard.server.common.data.ai.provider.MistralAiProviderConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public record MistralAiChatModel(
|
public record MistralAiChatModel(
|
||||||
AiModelType modelType,
|
AiModelType modelType,
|
||||||
MistralAiProviderConfig providerConfig,
|
MistralAiProviderConfig providerConfig,
|
||||||
@ -34,6 +36,7 @@ public record MistralAiChatModel(
|
|||||||
Double frequencyPenalty,
|
Double frequencyPenalty,
|
||||||
Double presencePenalty,
|
Double presencePenalty,
|
||||||
Integer maxOutputTokens,
|
Integer maxOutputTokens,
|
||||||
|
List<String> stopSequences,
|
||||||
Integer timeoutSeconds,
|
Integer timeoutSeconds,
|
||||||
Integer maxRetries
|
Integer maxRetries
|
||||||
) implements AiChatModelConfig<MistralAiChatModel.Config> {}
|
) implements AiChatModelConfig<MistralAiChatModel.Config> {}
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import lombok.With;
|
|||||||
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
import org.thingsboard.server.common.data.ai.model.AiModelType;
|
||||||
import org.thingsboard.server.common.data.ai.provider.OpenAiProviderConfig;
|
import org.thingsboard.server.common.data.ai.provider.OpenAiProviderConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public record OpenAiChatModel(
|
public record OpenAiChatModel(
|
||||||
AiModelType modelType,
|
AiModelType modelType,
|
||||||
OpenAiProviderConfig providerConfig,
|
OpenAiProviderConfig providerConfig,
|
||||||
@ -34,6 +36,7 @@ public record OpenAiChatModel(
|
|||||||
Double frequencyPenalty,
|
Double frequencyPenalty,
|
||||||
Double presencePenalty,
|
Double presencePenalty,
|
||||||
Integer maxOutputTokens,
|
Integer maxOutputTokens,
|
||||||
|
List<String> stopSequences,
|
||||||
Integer timeoutSeconds,
|
Integer timeoutSeconds,
|
||||||
Integer maxRetries
|
Integer maxRetries
|
||||||
) implements AiChatModelConfig<OpenAiChatModel.Config> {}
|
) implements AiChatModelConfig<OpenAiChatModel.Config> {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user