Skip to content

Commit f9cdd8e

Browse files
eeaterschedim
authored andcommitted
refactor: remove obsolete templateRenderer from AdvisorChain
The templateRenderer is no longer required within the AdvisorChain itself, as template rendering now occurs during the construction of the ChatClientRequest. This field was unused and has been removed to clean up the code. Signed-off-by: eeaters <[email protected]>
1 parent 40101fc commit f9cdd8e

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

spring-ai-client-chat/src/main/java/org/springframework/ai/chat/client/DefaultChatClient.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,10 +1006,7 @@ private BaseAdvisorChain buildAdvisorChain() {
10061006
this.advisors.add(ChatModelCallAdvisor.builder().chatModel(this.chatModel).build());
10071007
this.advisors.add(ChatModelStreamAdvisor.builder().chatModel(this.chatModel).build());
10081008

1009-
return DefaultAroundAdvisorChain.builder(this.observationRegistry)
1010-
.pushAll(this.advisors)
1011-
.templateRenderer(this.templateRenderer)
1012-
.build();
1009+
return DefaultAroundAdvisorChain.builder(this.observationRegistry).pushAll(this.advisors).build();
10131010
}
10141011

10151012
}

spring-ai-client-chat/src/main/java/org/springframework/ai/chat/client/advisor/DefaultAroundAdvisorChain.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.springframework.ai.template.TemplateRenderer;
3939
import org.springframework.ai.template.st.StTemplateRenderer;
4040
import org.springframework.core.OrderComparator;
41-
import org.springframework.lang.Nullable;
4241
import org.springframework.util.Assert;
4342
import org.springframework.util.CollectionUtils;
4443

@@ -68,17 +67,14 @@ public class DefaultAroundAdvisorChain implements BaseAdvisorChain {
6867

6968
private final ObservationRegistry observationRegistry;
7069

71-
private final TemplateRenderer templateRenderer;
72-
73-
DefaultAroundAdvisorChain(ObservationRegistry observationRegistry, @Nullable TemplateRenderer templateRenderer,
74-
Deque<CallAdvisor> callAdvisors, Deque<StreamAdvisor> streamAdvisors) {
70+
DefaultAroundAdvisorChain(ObservationRegistry observationRegistry, Deque<CallAdvisor> callAdvisors,
71+
Deque<StreamAdvisor> streamAdvisors) {
7572

7673
Assert.notNull(observationRegistry, "the observationRegistry must be non-null");
7774
Assert.notNull(callAdvisors, "the callAdvisors must be non-null");
7875
Assert.notNull(streamAdvisors, "the streamAdvisors must be non-null");
7976

8077
this.observationRegistry = observationRegistry;
81-
this.templateRenderer = templateRenderer != null ? templateRenderer : DEFAULT_TEMPLATE_RENDERER;
8278
this.callAdvisors = callAdvisors;
8379
this.streamAdvisors = streamAdvisors;
8480
this.originalCallAdvisors = List.copyOf(callAdvisors);
@@ -164,19 +160,12 @@ public static class Builder {
164160

165161
private final Deque<StreamAdvisor> streamAdvisors;
166162

167-
private TemplateRenderer templateRenderer;
168-
169163
public Builder(ObservationRegistry observationRegistry) {
170164
this.observationRegistry = observationRegistry;
171165
this.callAdvisors = new ConcurrentLinkedDeque<>();
172166
this.streamAdvisors = new ConcurrentLinkedDeque<>();
173167
}
174168

175-
public Builder templateRenderer(TemplateRenderer templateRenderer) {
176-
this.templateRenderer = templateRenderer;
177-
return this;
178-
}
179-
180169
public Builder push(Advisor advisor) {
181170
Assert.notNull(advisor, "the advisor must be non-null");
182171
return this.pushAll(List.of(advisor));
@@ -225,8 +214,7 @@ private void reOrder() {
225214
}
226215

227216
public DefaultAroundAdvisorChain build() {
228-
return new DefaultAroundAdvisorChain(this.observationRegistry, this.templateRenderer, this.callAdvisors,
229-
this.streamAdvisors);
217+
return new DefaultAroundAdvisorChain(this.observationRegistry, this.callAdvisors, this.streamAdvisors);
230218
}
231219

232220
}

0 commit comments

Comments
 (0)