Commit 0308d2a
authored
fix(admin): guard null topK/threshold in KnowledgeBaseDocumentRetriever (#4736)
The public retrieve(Query) auto-unboxes searchOptions.getSimilarityThreshold()
in the filter and searchOptions.getTopK() in the limit, so it throws an NPE
on the first RAG-backed chat turn whenever the agent-level FileSearchOptions
leaves topK/similarityThreshold unset (the default). The private
retrieve(KnowledgeBase, Query) in the same class already null-checks both;
mirror that null-safety here.
When topK is null the merged results are returned uncapped (Long.MAX_VALUE)
and a null similarityThreshold skips the threshold filter — per-KB retrieval
already applied its own. Resolves the NPE reported in #4734.
Optional companion (not included): adding @Builder.Default to
FileSearchOptions.topK/similarityThreshold would make the documented defaults
of 3 / 0.2 actually apply — left as a maintainer decision on the intended
semantics.1 parent 03e18e8 commit 0308d2a
1 file changed
Lines changed: 5 additions & 2 deletions
File tree
- spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/rag/retriever
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | | - | |
102 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| |||
0 commit comments