Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1006,10 +1006,7 @@ private BaseAdvisorChain buildAdvisorChain() {
this.advisors.add(ChatModelCallAdvisor.builder().chatModel(this.chatModel).build());
this.advisors.add(ChatModelStreamAdvisor.builder().chatModel(this.chatModel).build());

return DefaultAroundAdvisorChain.builder(this.observationRegistry)
.pushAll(this.advisors)
.templateRenderer(this.templateRenderer)
.build();
return DefaultAroundAdvisorChain.builder(this.observationRegistry).pushAll(this.advisors).build();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.springframework.ai.template.TemplateRenderer;
import org.springframework.ai.template.st.StTemplateRenderer;
import org.springframework.core.OrderComparator;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;

Expand Down Expand Up @@ -68,17 +67,14 @@ public class DefaultAroundAdvisorChain implements BaseAdvisorChain {

private final ObservationRegistry observationRegistry;

private final TemplateRenderer templateRenderer;

DefaultAroundAdvisorChain(ObservationRegistry observationRegistry, @Nullable TemplateRenderer templateRenderer,
Deque<CallAdvisor> callAdvisors, Deque<StreamAdvisor> streamAdvisors) {
DefaultAroundAdvisorChain(ObservationRegistry observationRegistry, Deque<CallAdvisor> callAdvisors,
Deque<StreamAdvisor> streamAdvisors) {

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

this.observationRegistry = observationRegistry;
this.templateRenderer = templateRenderer != null ? templateRenderer : DEFAULT_TEMPLATE_RENDERER;
this.callAdvisors = callAdvisors;
this.streamAdvisors = streamAdvisors;
this.originalCallAdvisors = List.copyOf(callAdvisors);
Expand Down Expand Up @@ -164,19 +160,12 @@ public static class Builder {

private final Deque<StreamAdvisor> streamAdvisors;

private TemplateRenderer templateRenderer;

public Builder(ObservationRegistry observationRegistry) {
this.observationRegistry = observationRegistry;
this.callAdvisors = new ConcurrentLinkedDeque<>();
this.streamAdvisors = new ConcurrentLinkedDeque<>();
}

public Builder templateRenderer(TemplateRenderer templateRenderer) {
this.templateRenderer = templateRenderer;
return this;
}

public Builder push(Advisor advisor) {
Assert.notNull(advisor, "the advisor must be non-null");
return this.pushAll(List.of(advisor));
Expand Down Expand Up @@ -225,8 +214,7 @@ private void reOrder() {
}

public DefaultAroundAdvisorChain build() {
return new DefaultAroundAdvisorChain(this.observationRegistry, this.templateRenderer, this.callAdvisors,
this.streamAdvisors);
return new DefaultAroundAdvisorChain(this.observationRegistry, this.callAdvisors, this.streamAdvisors);
}

}
Expand Down