Skip to content

Commit

Permalink
Fixes issue with HttpClient configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Gasser committed Aug 6, 2024
1 parent 549285e commit 739f618
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@ abstract class AbstractApi<I, O>(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
socketTimeoutMillis = timeoutMs
}
}

/** 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" }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AudioContent, Value.String>(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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pair<ImageContent, TextContent>, 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImageContent, Value.FloatVector>(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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImageContent, Value.String>(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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImageContent, Value.FloatVector>(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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImageContent, List<Value.String>>(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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImageContent, Value.String>(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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextContent, Value.FloatVector>(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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pair<ImageContent, List<String>>, List<Value.Double>>(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.
Expand Down

0 comments on commit 739f618

Please sign in to comment.