Skip to content

Commit 9ffaa72

Browse files
committed
refactor: ktlintformat
1 parent 12d1d59 commit 9ffaa72

File tree

8 files changed

+40
-47
lines changed

8 files changed

+40
-47
lines changed

noweekend-clients/client-mcp/src/main/kotlin/noweekend/client/mcp/recommend/RecommendClient.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ class RecommendClient(
8686
return try {
8787
api.getSandwich(request)
8888
} catch (e: FeignException) {
89-
log.warn("[getSandwich] FeignException, empty 반환. msg=${e.message}")
89+
log.warn("[getSandwich] FeignException occurred. msg=${e.message}")
9090
throw McpNotRespondingException()
9191
} catch (e: Exception) {
92-
log.error("[getSandwich] 예기치 못한 예외, empty 반환.", e)
92+
log.error("[getSandwich] Unexpected exception occurred.", e)
9393
throw McpNotRespondingException()
9494
}
9595
}

noweekend-mcp/mcp-host/src/main/kotlin/noweekend/mcphost/McpHostApplication.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ class McpHostApplication
99
fun main(args: Array<String>) {
1010
runApplication<McpHostApplication>(*args)
1111
}
12-

noweekend-mcp/mcp-host/src/main/kotlin/noweekend/mcphost/config/RestTemplateConfig.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package noweekend.mcphost.config
22

3-
import org.springframework.http.MediaType
4-
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
53
import org.springframework.context.annotation.Bean
64
import org.springframework.context.annotation.Configuration
5+
import org.springframework.http.MediaType
76
import org.springframework.http.converter.HttpMessageConverter
7+
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
88
import org.springframework.web.client.RestTemplate
99

1010
@Configuration
@@ -17,12 +17,11 @@ class RestTemplateConfig {
1717
MediaType.TEXT_XML,
1818
MediaType.APPLICATION_XML,
1919
MediaType.TEXT_PLAIN,
20-
MediaType.ALL
20+
MediaType.ALL,
2121
)
2222
}
2323
return RestTemplate().apply {
2424
messageConverters = listOf<HttpMessageConverter<*>>(converter)
2525
}
2626
}
2727
}
28-

noweekend-mcp/mcp-host/src/main/kotlin/noweekend/mcphost/controller/ChatbotController.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package noweekend.mcphost.controller
22

3-
import noweekend.mcphost.controller.request.Tag
4-
import noweekend.mcphost.controller.request.TagRequest
5-
import noweekend.mcphost.controller.request.WeatherRequest
6-
import noweekend.mcphost.controller.response.WeatherResponse
73
import noweekend.mcphost.controller.request.AiGenerateVacationRequest
84
import noweekend.mcphost.controller.request.AiGenerateVacationResponse
95
import noweekend.mcphost.controller.request.SandwichRequest
6+
import noweekend.mcphost.controller.request.Tag
7+
import noweekend.mcphost.controller.request.TagRequest
8+
import noweekend.mcphost.controller.request.WeatherRequest
109
import noweekend.mcphost.controller.response.BridgeVacationPeriod
10+
import noweekend.mcphost.controller.response.WeatherResponse
1111
import noweekend.mcphost.service.ChatbotService
12-
import org.slf4j.LoggerFactory
1312
import org.springframework.http.MediaType
1413
import org.springframework.web.bind.annotation.PostMapping
1514
import org.springframework.web.bind.annotation.RequestBody
@@ -19,8 +18,6 @@ import org.springframework.web.bind.annotation.RestController
1918
class ChatbotController(
2019
private val chatbotService: ChatbotService,
2120
) {
22-
private val logger = LoggerFactory.getLogger(ChatbotController::class.java)
23-
2421
@PostMapping(
2522
"/getFutureWeather",
2623
produces = [MediaType.APPLICATION_JSON_VALUE],
@@ -48,4 +45,4 @@ class ChatbotController(
4845
fun getTagOnlyNew(@RequestBody request: AiGenerateVacationRequest): AiGenerateVacationResponse {
4946
return chatbotService.generateVacation(request)
5047
}
51-
}
48+
}

noweekend-mcp/mcp-host/src/main/kotlin/noweekend/mcphost/controller/Prompt.kt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import java.util.Locale
1111
class Prompt(
1212
private val objectMapper: ObjectMapper,
1313
) {
14-
val WEATHER_PROMPT = """
14+
val weatherPrompt = """
1515
You MUST call the TOOL to get the weather data.
1616
DO NOT generate, guess, or hallucinate weather data yourself.
1717
ALWAYS use the TOOL OUTPUT ONLY to create your answer.
@@ -56,9 +56,9 @@ AGAIN:
5656
- Only output dates where you can recommend "연차" or "반차" according to the rules above.
5757
- Never output a recommendation like "연차 쓰지 마세요" or "휴가를 추천하지 않습니다".
5858
59-
""".trimIndent()
59+
""".trimIndent()
6060

61-
val TAG_SYSTEM_PROMPT = """
61+
val tagSystemPrompt = """
6262
You are an assistant specialized in Korean lifestyle and activity tag recommendations for daily schedules.
6363
6464
Your ONLY allowed output is a valid JSON array of 3 tag objects as shown below. If you output anything else, your answer is invalid.
@@ -86,9 +86,9 @@ Output example:
8686
]
8787
8888
Return ONLY this JSON array. Never add any other text, explanation, or formatting.
89-
""".trimIndent()
89+
""".trimIndent()
9090

91-
val ONLY_NEW_TAG_PROMPT = """
91+
val onlyNewTagSystemPrompt = """
9292
You are an expert assistant for tag recommendations.
9393
9494
Below is a JSON object representing the user's tag lists, all in Korean.
@@ -116,7 +116,7 @@ Return ONLY this JSON array. Never add any other text, explanation, or formattin
116116
]
117117
118118
Here is the user's tag information in JSON:
119-
""".trimIndent()
119+
""".trimIndent()
120120

121121
/**
122122
* 1단계: 생일·공휴일·주말·연차를 조합해 최대 연속 휴가 날짜(dates)를 계산
@@ -143,15 +143,15 @@ RULES:
143143
144144
OUTPUT:
145145
{"dates":["YYYY-MM-DD", ...]}
146-
""".trimIndent()
146+
""".trimIndent()
147147
}
148148

149149
fun detailedPlanPrompt(
150150
req: AiGenerateVacationRequest,
151151
dates: List<String>,
152152
offset: Int,
153153
totalDays: Int,
154-
prevUsed: List<String>
154+
prevUsed: List<String>,
155155
): String {
156156
val headers = dates.mapIndexed { i, d ->
157157
val num = offset + i + 1
@@ -160,9 +160,11 @@ OUTPUT:
160160
"• Day $num ($label)"
161161
}.joinToString("\n")
162162

163-
val usedClause = if (prevUsed.isNotEmpty())
163+
val usedClause = if (prevUsed.isNotEmpty()) {
164164
"Recently used items: ${prevUsed.joinToString(", ")}.\nDo NOT reuse in this block.\n\n"
165-
else ""
165+
} else {
166+
""
167+
}
166168

167169
// profile JSON with Korean tags
168170
val profileJson = objectMapper.writeValueAsString(
@@ -172,8 +174,8 @@ OUTPUT:
172174
"restPreference" to req.chosenRestPreferenceLabel,
173175
"leisurePreference" to req.chosenLeisurePreferenceLabel,
174176
"preferredTags" to req.selectedTags,
175-
"excludedTags" to req.unselectedTags
176-
)
177+
"excludedTags" to req.unselectedTags,
178+
),
177179
)
178180

179181
return """
@@ -216,6 +218,6 @@ HEADERS:
216218
$headers
217219
218220
Now generate the itinerary.
219-
""".trimIndent()
221+
""".trimIndent()
220222
}
221-
}
223+
}

noweekend-mcp/mcp-host/src/main/kotlin/noweekend/mcphost/controller/request/WeatherRequest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ package noweekend.mcphost.controller.request
33
data class WeatherRequest(
44
val latitude: Double,
55
val longitude: Double,
6-
)
6+
)

noweekend-mcp/mcp-host/src/main/kotlin/noweekend/mcphost/controller/response/BridgeVacationPeriod.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ import java.time.LocalDate
55
data class BridgeVacationPeriod(
66
val startDate: LocalDate,
77
val endDate: LocalDate,
8-
)
8+
)

noweekend-mcp/mcp-host/src/main/kotlin/noweekend/mcphost/service/ChatbotService.kt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import com.fasterxml.jackson.databind.ObjectMapper
44
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
55
import com.fasterxml.jackson.module.kotlin.readValue
66
import noweekend.mcphost.controller.Prompt
7-
import noweekend.mcphost.controller.request.Tag
8-
import noweekend.mcphost.controller.request.TagRequest
97
import noweekend.mcphost.controller.request.AiGenerateVacationRequest
108
import noweekend.mcphost.controller.request.AiGenerateVacationResponse
119
import noweekend.mcphost.controller.request.SandwichRequest
10+
import noweekend.mcphost.controller.request.Tag
11+
import noweekend.mcphost.controller.request.TagRequest
1212
import noweekend.mcphost.controller.request.WeatherRequest
1313
import noweekend.mcphost.controller.response.BridgeVacationPeriod
1414
import noweekend.mcphost.controller.response.WeatherResponse
@@ -46,7 +46,7 @@ class ChatbotService(
4646
for (attempt in 0 until maxRetries) {
4747
try {
4848
val jsonString = chatClient.prompt()
49-
.system(prompt.WEATHER_PROMPT)
49+
.system(prompt.weatherPrompt)
5050
.user(userMsg)
5151
.call()
5252
.content()
@@ -81,7 +81,7 @@ Based on the above rules, return ONLY a valid JSON array of 3 Korean lifestyle a
8181
repeat(7) { attempt ->
8282
try {
8383
val rawResponse = chatClient.prompt()
84-
.system(prompt.TAG_SYSTEM_PROMPT)
84+
.system(prompt.tagSystemPrompt)
8585
.user(userPrompt)
8686
.call()
8787
.content()
@@ -124,7 +124,7 @@ Based on the above rules, return ONLY a valid JSON array of 3 Korean lifestyle a
124124

125125
repeat(5) { attempt ->
126126
val jsonString = chatClient.prompt()
127-
.system(prompt.ONLY_NEW_TAG_PROMPT)
127+
.system(prompt.onlyNewTagSystemPrompt)
128128
.user(userMsg)
129129
.call()
130130
.content()
@@ -134,9 +134,9 @@ Based on the above rules, return ONLY a valid JSON array of 3 Korean lifestyle a
134134
if (jsonString != null) {
135135
val tags: List<Tag> = objectMapper.readValue(jsonString)
136136
val allOldTags = (
137-
request.userTag.selectedBasicTags + request.userTag.unselectedBasicTags +
138-
request.userTag.selectedCustomTags + request.userTag.unselectedCustomTags
139-
).map { it.content }.toSet()
137+
request.userTag.selectedBasicTags + request.userTag.unselectedBasicTags +
138+
request.userTag.selectedCustomTags + request.userTag.unselectedCustomTags
139+
).map { it.content }.toSet()
140140
require(tags.all { it.content !in allOldTags }) { "추천 결과에 기존 태그가 포함됨" }
141141
return tags
142142
}
@@ -191,7 +191,6 @@ Based on the above rules, return ONLY a valid JSON array of 3 Korean lifestyle a
191191
usedItems += extractUsedItems(content)
192192
chunkCache[idx] = content
193193
return@mapIndexed content
194-
195194
} catch (e: NonTransientAiException) {
196195
val cause = e.cause
197196
val status = (cause as? RestClientResponseException)?.statusCode?.value()
@@ -210,8 +209,6 @@ Based on the above rules, return ONLY a valid JSON array of 3 Korean lifestyle a
210209
throw e
211210
}
212211
}
213-
214-
215212
}
216213

217214
val planRaw = itineraryChunks.joinToString("\n\n")
@@ -221,23 +218,22 @@ Based on the above rules, return ONLY a valid JSON array of 3 Korean lifestyle a
221218
"""
222219
You are an expert at creating concise and catchy Korean titles for vacation plans.
223220
Summarize core concept in 15 characters max, Korean only.
224-
""".trimIndent(),
221+
""".trimIndent(),
225222
)
226223
.user(
227224
"""
228225
아래는 사용자 일정입니다:
229226
$planRaw
230227
231228
핵심 키워드 중심으로 15자 이내 제목 하나 만들어 주세요.
232-
""".trimIndent(),
229+
""".trimIndent(),
233230
)
234231
.call()
235232
.content() ?: error("제목 요약 실패")
236233

237234
return AiGenerateVacationResponse(title = summary, content = planRaw)
238235
}
239236

240-
241237
private fun minimalProfileMap(req: AiGenerateVacationRequest) = mapOf(
242238
"days" to req.days,
243239
"travelStyle" to req.chosenTravelStyleLabel,
@@ -306,7 +302,7 @@ EXAMPLE (must follow this format exactly):
306302
]
307303
308304
***Return ONLY a JSON array as above. No explanation, markdown, or extra text.***
309-
""".trimIndent()
305+
""".trimIndent()
310306

311307
val objectMapper = jacksonObjectMapper().findAndRegisterModules()
312308

@@ -343,4 +339,4 @@ EXAMPLE (must follow this format exactly):
343339
}
344340
throw IllegalStateException("Failed to get valid bridge vacation periods after 5 attempts", lastException)
345341
}
346-
}
342+
}

0 commit comments

Comments
 (0)