Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ArticleAiSummaryProperties {
private int failedRetryWindowStartHour = 0;
private int failedRetryWindowEndHour = 4;
private int requestTimeoutSeconds = 120;
private int chatRequestTimeoutSeconds = 120;
private int chatRequestTimeoutSeconds = 600;
private int documentParseRequestTimeoutSeconds = 180;
private int documentDownloadTimeoutSeconds = 60;
private String model = "solar-pro4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ private Map<String, Object> requestBody(ArticleSummaryPrompt prompt) {
),
"temperature", 0.2,
"top_p", 0.9,
"max_tokens", 500,
"reasoning_effort", "low",
"response_format", responseFormat(prompt.maxItems())
);
Expand Down Expand Up @@ -143,9 +142,17 @@ private String extractContent(ChatCompletionResponse response) {
if (response == null || response.choices() == null || response.choices().isEmpty()) {
throw new ArticleSummaryExternalApiException("Upstage 요약 응답이 비어 있습니다.", true, null);
}
String content = response.choices().get(0).message().content();
Choice choice = response.choices().get(0);
String content = choice.message() == null ? null : choice.message().content();
if (!StringUtils.hasText(content)) {
throw new ArticleSummaryExternalApiException("Upstage 요약 본문이 비어 있습니다.", true, null);
String finishReason = StringUtils.hasText(choice.finishReason())
? " finish_reason=%s".formatted(choice.finishReason())
: "";
throw new ArticleSummaryExternalApiException(
"Upstage 요약 본문이 비어 있습니다." + finishReason,
true,
null
);
}
return content;
}
Expand Down Expand Up @@ -219,7 +226,8 @@ private record ChatCompletionResponse(

@JsonIgnoreProperties(ignoreUnknown = true)
private record Choice(
Message message
Message message,
@JsonProperty("finish_reason") String finishReason
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ article:
failed-retry-window-start-hour: ${ARTICLE_AI_SUMMARY_FAILED_RETRY_WINDOW_START_HOUR:0}
failed-retry-window-end-hour: ${ARTICLE_AI_SUMMARY_FAILED_RETRY_WINDOW_END_HOUR:4}
request-timeout-seconds: ${ARTICLE_AI_SUMMARY_REQUEST_TIMEOUT_SECONDS:120}
chat-request-timeout-seconds: ${ARTICLE_AI_SUMMARY_CHAT_REQUEST_TIMEOUT_SECONDS:120}
chat-request-timeout-seconds: ${ARTICLE_AI_SUMMARY_CHAT_REQUEST_TIMEOUT_SECONDS:600}
document-parse-request-timeout-seconds: ${ARTICLE_AI_SUMMARY_DOCUMENT_PARSE_REQUEST_TIMEOUT_SECONDS:180}
document-download-timeout-seconds: ${ARTICLE_AI_SUMMARY_DOCUMENT_DOWNLOAD_TIMEOUT_SECONDS:60}
model: ${ARTICLE_AI_SUMMARY_MODEL:solar-pro4}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class UpstageArticleSummaryClientTest {

assertThat(requestBody)
.containsEntry("model", "solar-pro4")
.containsKey("response_format");
.containsEntry("reasoning_effort", "low")
.containsKey("response_format")
.doesNotContainKey("max_tokens");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ class ArticleAiSummaryPropertiesTest {

assertThat(properties.getModel()).isEqualTo("solar-pro4");
assertThat(properties.getPromptVersion()).isEqualTo("v11");
assertThat(properties.getChatRequestTimeoutSeconds()).isEqualTo(600);
}
}
Loading