10 changed files with 116 additions and 8 deletions
@ -0,0 +1,60 @@ |
|||||
|
/** |
||||
|
* 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 org.thingsboard.server.common.data.ai.provider.GithubModelsProviderConfig; |
||||
|
|
||||
|
public record GitHubModelsChatModel( |
||||
|
GithubModelsProviderConfig providerConfig, |
||||
|
Config modelConfig |
||||
|
) implements AiChatModel<GitHubModelsChatModel.Config> { |
||||
|
|
||||
|
public record Config( |
||||
|
String modelId, |
||||
|
Double temperature, |
||||
|
Integer timeoutSeconds, |
||||
|
Integer maxRetries |
||||
|
) implements AiChatModelConfig<GitHubModelsChatModel.Config> { |
||||
|
|
||||
|
@Override |
||||
|
public GitHubModelsChatModel.Config withTemperature(Double temperature) { |
||||
|
return new Config(modelId, temperature, timeoutSeconds, maxRetries); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public GitHubModelsChatModel.Config withTimeoutSeconds(Integer timeoutSeconds) { |
||||
|
return new Config(modelId, temperature, timeoutSeconds, maxRetries); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public GitHubModelsChatModel.Config withMaxRetries(Integer maxRetries) { |
||||
|
return new Config(modelId, temperature, timeoutSeconds, maxRetries); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ChatModel configure(Langchain4jChatModelConfigurer configurer) { |
||||
|
return configurer.configureChatModel(this); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public GitHubModelsChatModel withModelConfig(GitHubModelsChatModel.Config config) { |
||||
|
return new GitHubModelsChatModel(providerConfig, config); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
/** |
||||
|
* 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; |
||||
|
|
||||
|
public record GithubModelsProviderConfig(String personalAccessToken) implements AiProviderConfig { |
||||
|
|
||||
|
@Override |
||||
|
public AiProvider provider() { |
||||
|
return AiProvider.GITHUB_MODELS; |
||||
|
} |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue