@@ -92,7 +92,17 @@ class LLMHandler(
9292 articleToolRegistry + youtubeToolRegistry + bilibiliToolRegistry + fileToolRegistry
9393
9494 val agentConfig =
95- createAgentConfig(provider, model, summaryLength, showLength, useContentLanguage, appLanguage, isAppendMode, customBasePrompt, additionalSystemPrompt)
95+ createAgentConfig(
96+ provider,
97+ model,
98+ summaryLength,
99+ showLength,
100+ useContentLanguage,
101+ appLanguage,
102+ isAppendMode,
103+ customBasePrompt,
104+ additionalSystemPrompt
105+ )
96106
97107 return AIAgent (
98108 promptExecutor = executor,
@@ -151,47 +161,85 @@ class LLMHandler(
151161
152162 val lang = appLanguage.getDisplayLanguage(Locale .ENGLISH )
153163 return AIAgentConfig (
154- prompt = createSummarizationPrompt(summaryLength, showLength, useContentLanguage, lang, isAppendMode, customBasePrompt, additionalSystemPrompt),
164+ prompt = createSummarizationPrompt(
165+ summaryLength,
166+ showLength,
167+ useContentLanguage,
168+ lang,
169+ isAppendMode,
170+ customBasePrompt,
171+ additionalSystemPrompt
172+ ),
155173 model = llmModel,
156174 maxAgentIterations = 10 ,
157175 )
158176 }
159177
160178 private fun createOpenAIExecutor (apiKey : String , baseUrl : String? ): PromptExecutor {
161179 val client = baseUrl?.takeIf { it.isNotBlank() }
162- ?.let { OpenAILLMClient (apiKey, settings = OpenAIClientSettings (baseUrl = it), httpClientFactory = koogHttpClientFactory) }
180+ ?.let {
181+ OpenAILLMClient (
182+ apiKey,
183+ settings = OpenAIClientSettings (baseUrl = it),
184+ httpClientFactory = koogHttpClientFactory
185+ )
186+ }
163187 ? : OpenAILLMClient (apiKey, httpClientFactory = koogHttpClientFactory)
164188
165189 return MultiLLMPromptExecutor (client)
166190 }
167191
168192 private fun createGeminiExecutor (apiKey : String , baseUrl : String? ): PromptExecutor {
169193 val client = baseUrl?.takeIf { it.isNotBlank() }
170- ?.let { GoogleLLMClient (apiKey, settings = GoogleClientSettings (baseUrl = it), httpClientFactory = geminiKoogHttpClientFactory) }
194+ ?.let {
195+ GoogleLLMClient (
196+ apiKey,
197+ settings = GoogleClientSettings (baseUrl = it),
198+ httpClientFactory = geminiKoogHttpClientFactory
199+ )
200+ }
171201 ? : GoogleLLMClient (apiKey, httpClientFactory = geminiKoogHttpClientFactory)
172202
173203 return MultiLLMPromptExecutor (client)
174204 }
175205
176206 private fun createClaudExecutor (apiKey : String , baseUrl : String? ): PromptExecutor {
177207 val client = baseUrl?.takeIf { it.isNotBlank() }
178- ?.let { AnthropicLLMClient (apiKey, settings = AnthropicClientSettings (baseUrl = it), httpClientFactory = koogHttpClientFactory) }
208+ ?.let {
209+ AnthropicLLMClient (
210+ apiKey,
211+ settings = AnthropicClientSettings (baseUrl = it),
212+ httpClientFactory = koogHttpClientFactory
213+ )
214+ }
179215 ? : AnthropicLLMClient (apiKey, httpClientFactory = koogHttpClientFactory)
180216
181217 return MultiLLMPromptExecutor (client)
182218 }
183219
184220 private fun createDeepSeekExecutor (apiKey : String , baseUrl : String? ): PromptExecutor {
185221 val client = baseUrl?.takeIf { it.isNotBlank() }
186- ?.let { DeepSeekLLMClient (apiKey, settings = DeepSeekClientSettings (baseUrl = it), httpClientFactory = koogHttpClientFactory) }
222+ ?.let {
223+ DeepSeekLLMClient (
224+ apiKey,
225+ settings = DeepSeekClientSettings (baseUrl = it),
226+ httpClientFactory = koogHttpClientFactory
227+ )
228+ }
187229 ? : DeepSeekLLMClient (apiKey, httpClientFactory = koogHttpClientFactory)
188230
189231 return MultiLLMPromptExecutor (client)
190232 }
191233
192234 private fun createMistralExecutor (apiKey : String , baseUrl : String? ): PromptExecutor {
193235 val client = baseUrl?.takeIf { it.isNotBlank() }
194- ?.let { MistralAILLMClient (apiKey, settings = MistralAIClientSettings (baseUrl = it), httpClientFactory = koogHttpClientFactory) }
236+ ?.let {
237+ MistralAILLMClient (
238+ apiKey,
239+ settings = MistralAIClientSettings (baseUrl = it),
240+ httpClientFactory = koogHttpClientFactory
241+ )
242+ }
195243 ? : MistralAILLMClient (apiKey, httpClientFactory = koogHttpClientFactory)
196244
197245 return MultiLLMPromptExecutor (client)
@@ -211,7 +259,13 @@ class LLMHandler(
211259 baseUrl
212260 }
213261 val client = finalBaseUrl?.takeIf { it.isNotBlank() }
214- ?.let { DashscopeLLMClient (apiKey, settings = DashscopeClientSettings (baseUrl = it), httpClientFactory = koogHttpClientFactory) }
262+ ?.let {
263+ DashscopeLLMClient (
264+ apiKey,
265+ settings = DashscopeClientSettings (baseUrl = it),
266+ httpClientFactory = koogHttpClientFactory
267+ )
268+ }
215269 ? : DashscopeLLMClient (apiKey, httpClientFactory = koogHttpClientFactory)
216270
217271 return MultiLLMPromptExecutor (client)
@@ -227,7 +281,13 @@ class LLMHandler(
227281
228282 private fun createOpenRouterExecutor (apiKey : String , baseUrl : String? ): PromptExecutor {
229283 val client = baseUrl?.takeIf { it.isNotBlank() }
230- ?.let { OpenRouterLLMClient (apiKey, settings = OpenRouterClientSettings (baseUrl = it), httpClientFactory = koogHttpClientFactory) }
284+ ?.let {
285+ OpenRouterLLMClient (
286+ apiKey,
287+ settings = OpenRouterClientSettings (baseUrl = it),
288+ httpClientFactory = koogHttpClientFactory
289+ )
290+ }
231291 ? : OpenRouterLLMClient (apiKey, httpClientFactory = koogHttpClientFactory)
232292
233293 return MultiLLMPromptExecutor (client)
@@ -272,30 +332,38 @@ class LLMHandler(
272332 nodeStart forwardTo nodeExtractArticle
273333 onCondition { it is SummarySource .Article }
274334 transformed { source ->
275- val url = (source as SummarySource .Article ).url
276- sourceLink = url
277- Article (url)
278- }
335+ val url = (source as SummarySource .Article ).url
336+ sourceLink = url
337+ Article (url)
338+ }
279339 )
280340 edge(
281341 nodeStart forwardTo nodeExtractYoutube
282- onCondition { it is SummarySource .Video && YouTubeTranscriptTool .isYouTubeLink((it).url) }
342+ onCondition {
343+ it is SummarySource .Video && YouTubeTranscriptTool .isYouTubeLink(
344+ (it).url
345+ )
346+ }
283347 transformed { source ->
284- val url = (source as SummarySource .Video ).url
285- isYoutube = true
286- sourceLink = url
287- YouTubeTranscript (url)
288- }
348+ val url = (source as SummarySource .Video ).url
349+ isYoutube = true
350+ sourceLink = url
351+ YouTubeTranscript (url)
352+ }
289353 )
290354 edge(
291355 nodeStart forwardTo nodeExtractBiliBili
292- onCondition { it is SummarySource .Video && BiliBiliSubtitleTool .isBiliBiliLink((it).url) }
356+ onCondition {
357+ it is SummarySource .Video && BiliBiliSubtitleTool .isBiliBiliLink(
358+ (it).url
359+ )
360+ }
293361 transformed { source ->
294- val url = (source as SummarySource .Video ).url
295- isBiliBili = true
296- sourceLink = url
297- BiliBiliVideo (url)
298- }
362+ val url = (source as SummarySource .Video ).url
363+ isBiliBili = true
364+ sourceLink = url
365+ BiliBiliVideo (url)
366+ }
299367 )
300368 edge(
301369 nodeStart forwardTo nodeExtractFile
@@ -308,9 +376,21 @@ class LLMHandler(
308376 transformed { (it as SummarySource .Text ).content })
309377
310378 // Tool-based paths
311- edge(nodeExtractArticle forwardTo nodePreLLMRequest transformed { processToolResult(it) })
312- edge(nodeExtractYoutube forwardTo nodePreLLMRequest transformed { processToolResult(it) })
313- edge(nodeExtractBiliBili forwardTo nodePreLLMRequest transformed { processToolResult(it) })
379+ edge(nodeExtractArticle forwardTo nodePreLLMRequest transformed {
380+ processToolResult(
381+ it
382+ )
383+ })
384+ edge(nodeExtractYoutube forwardTo nodePreLLMRequest transformed {
385+ processToolResult(
386+ it
387+ )
388+ })
389+ edge(nodeExtractBiliBili forwardTo nodePreLLMRequest transformed {
390+ processToolResult(
391+ it
392+ )
393+ })
314394 edge(nodeExtractFile forwardTo nodePreLLMRequest transformed { processToolResult(it) })
315395 edge(nodePreLLMRequest forwardTo nodeFinish)
316396
0 commit comments