未来回调函数(Callbacks)
Java-friendly adapters for the engine's callback interfaces.
Every engine callback is an interface with a single suspend fun call(...), which no Java lambda or class can implement. Each factory pairs an engine callback with a CompletableFuture -returning functional interface and awaits it -- the same async idiom as the BaseFuture* SPI bases, with no blocking dispatcher. The sealed CallbackChoice return is built and read via Choices.
函数
在代理程序(agent)执行完成后运行。
在每次模型调用之后执行;可能会修改返回的结果(即响应数据)。
在每次工具调用之后执行;可能会修改最终结果。
在代理程序(agent)执行之前运行;返回结果。 Choices.proceed 继续还是……? Choices.breakWith 要跳过的内容。
在每次模型调用之前执行;可能会修改请求内容,或者直接返回响应(而无需等待模型处理结果)。
在每次调用工具之前执行;可能会修改输入参数,或者直接使用计算结果来替代参数。
当模型调用出现问题(即抛出异常)时,该代码会自动执行;它可以通过返回一个响应来“掩盖”(即隐藏)该错误。
当某个工具出现错误时,该程序会自动运行;它可以通过返回一个结果来“掩盖”(即隐藏)这个错误。