runOnLLMDispatcher

fun <T> AIAgentConfig.runOnLLMDispatcher(executorService: ExecutorService? = null, block: suspend () -> T): T(source)

Executes the given suspending block of code on the LLM dispatcher (suitable for IO / LLM communication) derived from the provided executorService, or falls back to Dispatchers.IO if none is supplied.

Return

The result of the executed suspending block.

Parameters

executorService

The custom ExecutorService to adapt as a coroutine context. If null, uses the default LLM executor service.

block

The suspending block of code to execute within the resolved coroutine context.

Type Parameters

T

The type of the result produced by the suspending block.