Browse Source
AI rule node: if specified, use request timeout from model config
pull/13371/head
Dmytro Skarzhynets
1 year ago
No known key found for this signature in database
GPG Key ID: 2B51652F224037DF
1 changed files with
4 additions and
1 deletions
-
application/src/main/java/org/thingsboard/server/controller/AiModelController.java
|
|
|
@ -31,6 +31,8 @@ import org.thingsboard.server.common.data.ai.model.chat.AiChatModel; |
|
|
|
import org.thingsboard.server.config.annotations.ApiOperation; |
|
|
|
import org.thingsboard.server.service.ai.AiModelService; |
|
|
|
|
|
|
|
import java.time.Duration; |
|
|
|
|
|
|
|
import static com.google.common.util.concurrent.MoreExecutors.directExecutor; |
|
|
|
import static org.thingsboard.server.controller.ControllerConstants.TENANT_AUTHORITY_PARAGRAPH; |
|
|
|
|
|
|
|
@ -57,7 +59,8 @@ class AiModelController extends BaseController { |
|
|
|
.transform(chatResponse -> (TbChatResponse) new TbChatResponse.Success(chatResponse.aiMessage().text()), directExecutor()) |
|
|
|
.catching(Throwable.class, ex -> new TbChatResponse.Failure(ex.getMessage()), directExecutor()); |
|
|
|
|
|
|
|
return wrapFuture(future); |
|
|
|
Integer requestTimeoutSeconds = chatModel.modelConfig().timeoutSeconds(); |
|
|
|
return requestTimeoutSeconds != null ? wrapFuture(future, Duration.ofSeconds(requestTimeoutSeconds).toMillis()) : wrapFuture(future); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|