Skip to content

Commit

Permalink
Strings are now trimmed upon reception.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Gasser committed Aug 6, 2024
1 parent db17efe commit 80d4226
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AsrApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Lo
* @return The [JobResult]
*/
override suspend fun pollJob(jobId: String): JobResult<Value.String> = try {
this.automatedSpeechRecognitionApi.getJobResultsApiTasksAutomatedSpeechRecognitionJobsJobGet(jobId).body().let { r -> JobResult(r.status, r.result?.transcript?.let { Value.String(it) }) }
this.automatedSpeechRecognitionApi.getJobResultsApiTasksAutomatedSpeechRecognitionJobsJobGet(jobId).body().let { r -> JobResult(r.status, r.result?.transcript?.let { Value.String(it.trim()) }) }
} catch (e: Throwable) {
JobResult(JobState.failed, null)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ConditionalImageCaptioningApi(host: String, model: String, timeoutMs: Long
*/
override suspend fun pollJob(jobId: String): JobResult<Value.String> = try {
this.conditionalImageCaptioningApi.getJobResultsApiTasksConditionalImageCaptioningJobsJobGet(jobId).body().let { result ->
JobResult(result.status, result.result?.caption?.let { Value.String(it) })
JobResult(result.status, result.result?.caption?.let { Value.String(it.trim()) })
}
} catch (e: Throwable) {
logger.error(e) { "Failed to poll for status of conditional image captioning job." }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ImageCaptioningApi(host: String, model: String, timeoutMs: Long, pollingIn
*/
override suspend fun pollJob(jobId: String): JobResult<Value.String> = try {
this.imageCaptioningApi.getJobResultsApiTasksImageCaptioningJobsJobGet(jobId).body().let { result ->
JobResult(result.status, result.result?.caption?.let { Value.String(it) })
JobResult(result.status, result.result?.caption?.let { Value.String(it.trim()) })
}
} catch (e: Throwable) {
logger.error(e) { "Failed to poll for status of image captioning job." }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ObjectDetectionApi(host: String, model: String, timeoutMs: Long, pollingIn
*/
override suspend fun pollJob(jobId: String): JobResult<List<Value.String>> = try {
this.objectDetectionApi.getJobResultsApiTasksObjectDetectionJobsJobGet(jobId).body().let { result ->
JobResult(result.status, result.result?.labels?.map { Value.String(it) })
JobResult(result.status, result.result?.labels?.map { Value.String(it.trim()) })
}
} catch (e: Throwable) {
logger.error(e) { "Failed to poll for status of object detection job." }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class OcrApi(host: String, model: String, timeoutMs: Long, pollingIntervalMs: Lo
*/
override suspend fun pollJob(jobId: String): JobResult<Value.String> = try {
this.opticalCharacterRecognitionApi.getJobResultsApiTasksOpticalCharacterRecognitionJobsJobGet(jobId).body().let { result ->
JobResult(result.status, result.result?.text?.let { Value.String(it) })
JobResult(result.status, result.result?.text?.let { Value.String(it.trim()) })
}
} catch (e: Throwable) {
logger.error(e) { "Failed to poll for status of OCR job." }
Expand Down

0 comments on commit 80d4226

Please sign in to comment.