Skip to content

Commit e18157e

Browse files
committed
strealine docs
1 parent 4f34890 commit e18157e

File tree

1 file changed

+8
-26
lines changed
  • spring-ai-docs/src/main/antora/modules/ROOT/pages/api

1 file changed

+8
-26
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/advisors.adoc

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55
The Spring AI Advisors API introduces a powerful component called `AroundAdvisor`.
66
This component dynamically intercepts chat-completion requests and responses, allowing for transformation or utilization of information within these interactions.
77

8-
The Advisors are important for a number of reasons:
8+
The key benefits include encapsulating recurring GenAI patterns, transforming data sent to and from Language Models (LLMs), and providing portability across various models and use cases.
99

10-
- Encapsulation of Recurring Tasks: AroundAdvisors enable the packaging of common GenAI patterns into reusable units.
11-
- Transformation: They facilitate the augmentation of data sent to Language Models (LLMs) and formatting of responses sent back to clients.
12-
- Portability: As part of the Spring AI core specification, developers can create reusable transformation components that work across various models and use cases.
13-
14-
The xref:api/chatclient.adoc#_advisor_configuration_in_chatclient[ChatClient API] provides a simple way to configure and use advisors. For example you can enable the built-in chat-memory and question-answer advisors like this:
10+
You can configure existing advisors using the xref:api/chatclient.adoc#_advisor_configuration_in_chatclient[ChatClient API] as shown in the following example:
1511

1612
[source,java]
1713
----
@@ -30,34 +26,20 @@ ChatClient.builder(chatModel)
3026
.call();
3127
----
3228

33-
The ChatClient API allows configuring advisors at build time and at runtime as well as providing parameters to the advisors.
34-
You can use some of the provided advisors or implement custom such to meet your specific requirements.
35-
3629
== Core Components
3730

38-
The Advisor API is defined in the `org.springframework.ai.chat.client.advisor.api` package by the pair of `CallAroundAdvisor` and `CallAroundAdvisorChain` interfaces and the corresponding `StreamAroundAdvisor` and `StreamAroundAdvisorChain` pair for the streaming responses.
31+
The API consists of `CallAroundAdvisor` and `CallAroundAdvisorChain` for non-streaming scenarios, and `StreamAroundAdvisor` and `StreamAroundAdvisorChain` for streaming scenarios.
32+
It also includes `AdvisedRequest` to represent the unsealed Prompt request, `AdvisedResponse` for the Chat Completion response. Both hold an `advise-context` to share state across the advisor chain.
3933

4034
image::advisors-api-classes.jpg[Advisors API Classes, width=600, align="center"]
4135

42-
The `AdvisedRequest` represents the unsealed Prompt request, while the `AdvisedResponse` represents the Chat Completion response.
43-
Both contain an `AdviserContext` object for sharing state across the advisor chain.
44-
45-
The `nextAroundCall()` and the `nextAroundStream()` are the key advisor methods, typically performing actions like:
46-
47-
- Examining the unsealed Prompt data
48-
- Customizing and augmenting the Prompt data
49-
- Invoking the next entity in the advisor chain
50-
- Optionally blocking the request
51-
- Examining the chat completion response
52-
- Throwing exceptions to indicate processing errors
36+
The `nextAroundCall()` and the `nextAroundStream()` are the key advisor methods, typically performing actions such as examining the unsealed Prompt data, customizing and augmenting the Prompt data, invoking the next entity in the advisor chain, optionally blocking the request, examining the chat completion response, and throwing exceptions to indicate processing errors.
5337

54-
In addition the `getOrder()` method determines the advisor's priority in the chain and the `getName()` method provides a unique identifier for the advisor.
38+
In addition the `getOrder()` method determines advisor priority in the chain, while `getName()` provides a unique identifier for the advisor.
5539

56-
The `Advisor Chain`, created and provided by the Spring AI framework, allows for the sequential invocation of multiple advisors.
57-
This chain is represented by `CallAroundAdvisorChain` for non-streaming and `StreamAroundAdvisorChain` for streaming scenarios.
58-
You add advisors to the chain using the The xref:api/chatclient.adoc#_advisor_configuration_in_chatclient[ChatClient API].
40+
The Advisor Chain, created by the Spring AI framework, allows sequential invocation of multiple advisors. It is ordered by `getOrder()` values, with lower values executing first. The last advisor, added automatically, sends the request to the LLM.
5941

60-
Following usage flow diagram illustrates the interaction between the advisor chain and the Chat Model:
42+
Following flow diagram illustrates the interaction between the advisor chain and the Chat Model:
6143

6244
image::advisors-flow.jpg[Advisors API Flow, width=400, align="left"]
6345

0 commit comments

Comments
 (0)