Skip to content

Commit adf4efe

Browse files
committed
Deprecate public constructor of QuestionAnswerAdvisor in favor of builder
And remove null check against searched documents since it never be null. Signed-off-by: Yanming Zhou <[email protected]>
1 parent 940bcf3 commit adf4efe

File tree

1 file changed

+10
-2
lines changed
  • advisors/spring-ai-advisors-vector-store/src/main/java/org/springframework/ai/chat/client/advisor/vectorstore

1 file changed

+10
-2
lines changed

advisors/spring-ai-advisors-vector-store/src/main/java/org/springframework/ai/chat/client/advisor/vectorstore/QuestionAnswerAdvisor.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
* @author Timo Salm
4949
* @author Ilayaperumal Gopinathan
5050
* @author Thomas Vitale
51+
* @author Yanming Zhou
5152
* @since 1.0.0
5253
*/
5354
public class QuestionAnswerAdvisor implements BaseAdvisor {
@@ -82,6 +83,12 @@ public class QuestionAnswerAdvisor implements BaseAdvisor {
8283

8384
private final int order;
8485

86+
/**
87+
* Construct instance by given VectorStore
88+
* @param vectorStore the given VectorStore
89+
* @deprecated in favor of {@link #builder(VectorStore)}}
90+
*/
91+
@Deprecated
8592
public QuestionAnswerAdvisor(VectorStore vectorStore) {
8693
this(vectorStore, SearchRequest.builder().build(), DEFAULT_PROMPT_TEMPLATE, BaseAdvisor.DEFAULT_SCHEDULER,
8794
DEFAULT_ORDER);
@@ -122,8 +129,9 @@ public ChatClientRequest before(ChatClientRequest chatClientRequest, AdvisorChai
122129
Map<String, Object> context = new HashMap<>(chatClientRequest.context());
123130
context.put(RETRIEVED_DOCUMENTS, documents);
124131

125-
String documentContext = documents == null ? ""
126-
: documents.stream().map(Document::getText).collect(Collectors.joining(System.lineSeparator()));
132+
String documentContext = documents.stream()
133+
.map(Document::getText)
134+
.collect(Collectors.joining(System.lineSeparator()));
127135

128136
// 3. Augment the user prompt with the document context.
129137
UserMessage userMessage = chatClientRequest.prompt().getUserMessage();

0 commit comments

Comments
 (0)