15 changed files with 146 additions and 20 deletions
@ -0,0 +1,57 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2025 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.common.data.ai.model.chat; |
||||
|
|
||||
|
import dev.langchain4j.model.chat.ChatModel; |
||||
|
import jakarta.validation.Valid; |
||||
|
import jakarta.validation.constraints.Max; |
||||
|
import jakarta.validation.constraints.NotBlank; |
||||
|
import jakarta.validation.constraints.NotNull; |
||||
|
import jakarta.validation.constraints.Positive; |
||||
|
import jakarta.validation.constraints.PositiveOrZero; |
||||
|
import lombok.Builder; |
||||
|
import lombok.With; |
||||
|
import org.thingsboard.server.common.data.ai.provider.AiProvider; |
||||
|
import org.thingsboard.server.common.data.ai.provider.OllamaProviderConfig; |
||||
|
|
||||
|
@Builder |
||||
|
public record OllamaChatModelConfig( |
||||
|
@NotNull @Valid OllamaProviderConfig providerConfig, |
||||
|
@NotBlank String modelId, |
||||
|
@PositiveOrZero Double temperature, |
||||
|
@Positive @Max(1) Double topP, |
||||
|
@PositiveOrZero Integer topK, |
||||
|
@Positive Integer maxOutputTokens, |
||||
|
@With @Positive Integer timeoutSeconds, |
||||
|
@With @PositiveOrZero Integer maxRetries |
||||
|
) implements AiChatModelConfig<OllamaChatModelConfig> { |
||||
|
|
||||
|
@Override |
||||
|
public AiProvider provider() { |
||||
|
return AiProvider.OLLAMA; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ChatModel configure(Langchain4jChatModelConfigurer configurer) { |
||||
|
return configurer.configureChatModel(this); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean supportsJsonMode() { |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2025 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.common.data.ai.provider; |
||||
|
|
||||
|
import jakarta.validation.constraints.NotBlank; |
||||
|
|
||||
|
public record OllamaProviderConfig( |
||||
|
@NotBlank String baseUrl |
||||
|
) implements AiProviderConfig {} |
||||
Loading…
Reference in new issue