Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.1.1 #55

Merged
merged 1 commit into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/main/kotlin/me/misik/api/app/CreateReviewFacade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.filterNot
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import me.misik.api.api.response.ParsedOcrResponse
import me.misik.api.core.Chatbot
import me.misik.api.core.GracefulShutdownDispatcher
Expand All @@ -18,6 +20,7 @@ import me.misik.api.domain.request.CreateReviewRequest
import me.misik.api.domain.request.OcrTextRequest
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
import kotlin.time.Duration.Companion.milliseconds

@Service
class CreateReviewFacade(
Expand Down Expand Up @@ -75,8 +78,12 @@ class CreateReviewFacade(
}

fun parseOcrText(ocrText: OcrTextRequest): ParsedOcrResponse {
val prompt = promptService.findAllByType(PromptType.OCR).first()
return parseOcrWithRetry(prompt, ocrText, 0)
return runBlocking(GracefulShutdownDispatcher.dispatcher) {
withTimeout(10.milliseconds) {
val prompt = promptService.findAllByType(PromptType.OCR).first()
parseOcrWithRetry(prompt, ocrText, 0)
}
}
}

private fun parseOcrWithRetry(
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/me/misik/api/domain/ReviewStyle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ enum class ReviewStyle(val iconUrl: String) {
PROFESSIONAL("https://kr.object.ncloudstorage.com/misik/review-style/professional-icon.png"),
FRIENDLY("https://kr.object.ncloudstorage.com/misik/review-style/friendly-icon.png"),
CUTE("https://kr.object.ncloudstorage.com/misik/review-style/cute-icon.png"),
OCR("NOT_USE"),
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ data class ReviewStylesResponse(
val reviewStyles: List<ReviewStyleResponse>
) {
companion object {
fun from(reviewStyles: List<ReviewStyle>) : ReviewStylesResponse {
fun from(reviewStyles: List<ReviewStyle>): ReviewStylesResponse {
return ReviewStylesResponse(
reviewStyles.map { ReviewStyleResponse.from(it) }
reviewStyles.filterNot { it != ReviewStyle.OCR }
.map { ReviewStyleResponse.from(it) }
)
}
}
}
}
Loading