From 739f61891c3ae94d604912cea3b06ffab22a70dd Mon Sep 17 00:00:00 2001 From: Ralph Gasser Date: Tue, 6 Aug 2024 11:33:14 +0200 Subject: [PATCH] Fixes issue with HttpClient configuration. --- .../vitrivr/engine/base/features/external/api/AbstractApi.kt | 5 +---- .../org/vitrivr/engine/base/features/external/api/AsrApi.kt | 2 +- .../features/external/api/ConditionalImageCaptioningApi.kt | 2 +- .../engine/base/features/external/api/FaceEmbeddingApi.kt | 2 +- .../engine/base/features/external/api/ImageCaptioningApi.kt | 2 +- .../engine/base/features/external/api/ImageEmbeddingApi.kt | 2 +- .../engine/base/features/external/api/ObjectDetectionApi.kt | 2 +- .../org/vitrivr/engine/base/features/external/api/OcrApi.kt | 2 +- .../engine/base/features/external/api/TextEmbeddingApi.kt | 2 +- .../base/features/external/api/ZeroShotClassificationApi.kt | 2 +- 10 files changed, 10 insertions(+), 13 deletions(-) diff --git a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/AbstractApi.kt b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/AbstractApi.kt index 1ff30878..c67028d5 100644 --- a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/AbstractApi.kt +++ b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/AbstractApi.kt @@ -30,7 +30,7 @@ abstract class AbstractApi(protected val host: String, protected val model } /** The HTTP client configuration. */ - private val httpClientConfig: HttpClientConfig<*>.() -> Unit = { + protected val httpClientConfig: HttpClientConfig<*>.() -> Unit = { install(HttpTimeout) { requestTimeoutMillis = timeoutMs connectTimeoutMillis = timeoutMs @@ -38,9 +38,6 @@ abstract class AbstractApi(protected val host: String, protected val model } } - /** The common [HttpClient] used by the [AbstractApi] instance. */ - protected val client: HttpClient = HttpClient(this.httpClientConfig) - init { logger.info { "Initialized API wrapper with host: $host, model: $model, timeout: $timeoutMs seconds, polling interval: $pollingIntervalMs ms" } } diff --git a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/AsrApi.kt b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/AsrApi.kt index 4f3cad41..a1ffcf6e 100644 --- a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/AsrApi.kt +++ b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/AsrApi.kt @@ -17,7 +17,7 @@ import org.vitrivr.engine.core.model.types.Value class AsrApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Long, retries: Int) : AbstractApi(host, model, timeoutMs, pollingIntervalMs, retries) { /** The API used for FES ASR. */ - private val automatedSpeechRecognitionApi by lazy { AutomatedSpeechRecognitionApi(baseUrl = host, httpClient = client) } + private val automatedSpeechRecognitionApi by lazy { AutomatedSpeechRecognitionApi(baseUrl = this.host, httpClientConfig = this.httpClientConfig) } /** * This method is used to start an ASR job on the API. diff --git a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ConditionalImageCaptioningApi.kt b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ConditionalImageCaptioningApi.kt index 4584bca7..5d96fea2 100644 --- a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ConditionalImageCaptioningApi.kt +++ b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ConditionalImageCaptioningApi.kt @@ -17,7 +17,7 @@ import org.vitrivr.engine.core.model.types.Value */ class ConditionalImageCaptioningApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Long, retries: Int) : AbstractApi, Value.String>(host, model, timeoutMs, pollingIntervalMs, retries) { /** The API used for FES conditional image captioning. */ - private val conditionalImageCaptioningApi by lazy { ConditionalImageCaptioningApi(baseUrl = host, httpClient = this.client) } + private val conditionalImageCaptioningApi by lazy { ConditionalImageCaptioningApi(baseUrl = this.host, httpClientConfig = this.httpClientConfig) } /** * This method is used to start a conditional image captioning job on the API. diff --git a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/FaceEmbeddingApi.kt b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/FaceEmbeddingApi.kt index 99af966b..e28e0f1e 100644 --- a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/FaceEmbeddingApi.kt +++ b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/FaceEmbeddingApi.kt @@ -17,7 +17,7 @@ import org.vitrivr.engine.core.model.types.Value class FaceEmbeddingApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Long, retries: Int) : AbstractApi(host, model, timeoutMs, pollingIntervalMs, retries) { /** The API used for FES face embedding. */ - private val faceEmbeddingApi by lazy { FaceEmbeddingApi(baseUrl = host, httpClient = this.client) } + private val faceEmbeddingApi by lazy { FaceEmbeddingApi(baseUrl = this.host, httpClientConfig = this.httpClientConfig) } /** * This method is used to start a face embedding job on the API. diff --git a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ImageCaptioningApi.kt b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ImageCaptioningApi.kt index e4b6bf2f..706caa7b 100644 --- a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ImageCaptioningApi.kt +++ b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ImageCaptioningApi.kt @@ -16,7 +16,7 @@ import org.vitrivr.engine.core.model.types.Value */ class ImageCaptioningApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Long, retries: Int) : AbstractApi(host, model, timeoutMs, pollingIntervalMs, retries) { /** The API used for FES image captioning. */ - private val imageCaptioningApi by lazy { ImageCaptioningApi(baseUrl = host, httpClient = client) } + private val imageCaptioningApi by lazy { ImageCaptioningApi(baseUrl = this.host, httpClientConfig = this.httpClientConfig) } /** * This method is used to start an image captioning job on the API. diff --git a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ImageEmbeddingApi.kt b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ImageEmbeddingApi.kt index 4ed1760a..4dbe22ee 100644 --- a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ImageEmbeddingApi.kt +++ b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ImageEmbeddingApi.kt @@ -17,7 +17,7 @@ import org.vitrivr.engine.core.model.types.Value class ImageEmbeddingApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Long, retries: Int) : AbstractApi(host, model, timeoutMs, pollingIntervalMs, retries) { /** The API used for FES image embedding. */ - private val imageEmbeddingApi by lazy { ImageEmbeddingApi(baseUrl = host, httpClient = client) } + private val imageEmbeddingApi by lazy { ImageEmbeddingApi(baseUrl = this.host, httpClientConfig = this.httpClientConfig) } /** * This method is used to start an image embedding job on the API. diff --git a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ObjectDetectionApi.kt b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ObjectDetectionApi.kt index ea7a6e52..6adf0d2c 100644 --- a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ObjectDetectionApi.kt +++ b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ObjectDetectionApi.kt @@ -17,7 +17,7 @@ import org.vitrivr.engine.core.model.types.Value class ObjectDetectionApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Long, retries: Int) : AbstractApi>(host, model, timeoutMs, pollingIntervalMs, retries) { /** The API used for FES object detection. */ - private val objectDetectionApi by lazy { ObjectDetectionApi(baseUrl = host, httpClient = this.client) } + private val objectDetectionApi by lazy { ObjectDetectionApi(baseUrl = this.host, httpClientConfig = this.httpClientConfig) } /** * This method is used to start an object detection job on the API. diff --git a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/OcrApi.kt b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/OcrApi.kt index 440125b5..cc409ef1 100644 --- a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/OcrApi.kt +++ b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/OcrApi.kt @@ -16,7 +16,7 @@ import org.vitrivr.engine.core.model.types.Value */ class OcrApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Long, retries: Int) : AbstractApi(host, model, timeoutMs, pollingIntervalMs, retries) { /** The API used for FES OCR. */ - private val opticalCharacterRecognitionApi by lazy { OpticalCharacterRecognitionApi(baseUrl = host, httpClient = this.client) } + private val opticalCharacterRecognitionApi by lazy { OpticalCharacterRecognitionApi(baseUrl = this.host, httpClientConfig = this.httpClientConfig) } /** * This method is used to start an OCR job on the API. diff --git a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/TextEmbeddingApi.kt b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/TextEmbeddingApi.kt index 815b05bc..1cf22254 100644 --- a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/TextEmbeddingApi.kt +++ b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/TextEmbeddingApi.kt @@ -17,7 +17,7 @@ import org.vitrivr.engine.core.model.types.Value class TextEmbeddingApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Long, retries: Int) : AbstractApi(host, model, timeoutMs, pollingIntervalMs, retries) { /** The API used for FES text embedding. */ - private val textEmbeddingApi by lazy { TextEmbeddingApi(baseUrl = host, httpClient = client) } + private val textEmbeddingApi by lazy { TextEmbeddingApi(baseUrl = this.host, httpClientConfig = this.httpClientConfig) } /** * This method is used to start an text embedding job on the API. diff --git a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ZeroShotClassificationApi.kt b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ZeroShotClassificationApi.kt index cdb2c80d..0d7c08ba 100644 --- a/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ZeroShotClassificationApi.kt +++ b/vitrivr-engine-module-fes/src/main/kotlin/org/vitrivr/engine/base/features/external/api/ZeroShotClassificationApi.kt @@ -17,7 +17,7 @@ import org.vitrivr.engine.core.model.types.Value class ZeroShotClassificationApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Long, retries: Int) : AbstractApi>, List>(host, model, timeoutMs, pollingIntervalMs, retries) { /** The API used for FES zero shot image classification. */ - private val zeroShotImageClassificationApi by lazy { ZeroShotImageClassificationApi(baseUrl = host, httpClient = client) } + private val zeroShotImageClassificationApi by lazy { ZeroShotImageClassificationApi(baseUrl = this.host, httpClientConfig = this.httpClientConfig) } /** * This method is used to start an zero shot image classification job on the API.