Create Self-Improving AI Agents Using Spring AI Recursive Advisors
The Spring AI ChatClient offers a fluent API for communicating with an AI model. The fluent API provides methods for building the constituent parts of a prompt that gets passed to the AI model as input.
Advisors are a key part of the fluent API that intercept, modify, and enhance AI-driven interactions. The key benefits include encapsulating common Generative AI patterns, transforming data sent to and from Large Language Models (LLMs), and providing portability across various models and use cases.
Advisors process ChatClientRequest and ChatClientResponse objects.
The framework chains advisors by their getOrder() values (lower values execute first), with the final…