Skip to content

Commit 4db5897

Browse files
committed
use DSEC order for the interaction history in chat agent
Signed-off-by: Xun Zhang <[email protected]>
1 parent 06c0380 commit 4db5897

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ml-algorithms/src/main/java/org/opensearch/ml/engine/memory/MLMemoryManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,14 @@ void innerGetFinalInteractions(String conversationId, int lastNInteraction, Acti
176176
searchRequest.source(searchSourceBuilder);
177177

178178
searchRequest.source().size(lastNInteraction);
179-
searchRequest.source().sort(ConversationalIndexConstants.INTERACTIONS_CREATE_TIME_FIELD, SortOrder.ASC);
179+
searchRequest.source().sort(ConversationalIndexConstants.INTERACTIONS_CREATE_TIME_FIELD, SortOrder.DESC);
180180

181181
try (ThreadContext.StoredContext threadContext = client.threadPool().getThreadContext().stashContext()) {
182182
ActionListener<List<Interaction>> internalListener = ActionListener.runBefore(listener, () -> threadContext.restore());
183183
ActionListener<SearchResponse> al = ActionListener.wrap(response -> {
184184
List<Interaction> result = new LinkedList<Interaction>();
185185
for (SearchHit hit : response.getHits()) {
186-
result.add(Interaction.fromSearchHit(hit));
186+
result.add(0, Interaction.fromSearchHit(hit));
187187
}
188188
internalListener.onResponse(result);
189189
}, e -> { internalListener.onFailure(e); });

0 commit comments

Comments
 (0)