Skip to content

Commit

Permalink
(fix)(chat)Remove spaces when obtaining a MemoryReviewResult
Browse files Browse the repository at this point in the history
  • Loading branch information
xiuzhu committed Aug 23, 2024
1 parent afa82bf commit 0a6a7de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
package com.tencent.supersonic.chat.api.pojo.enums;


import com.tencent.supersonic.common.pojo.exception.InvalidArgumentException;
import org.apache.commons.lang3.StringUtils;

public enum MemoryReviewResult {

POSITIVE,
NEGATIVE
NEGATIVE;

public static MemoryReviewResult getMemoryReviewResult(String value) {
String validValue = StringUtils.trim(value);
for (MemoryReviewResult reviewRet : MemoryReviewResult.values()) {
if (StringUtils.equalsIgnoreCase(reviewRet.name(), validValue)) {
return reviewRet;
}
}
throw new InvalidArgumentException("Invalid MemoryReviewResult type:[" + value +"]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void review() {

Matcher matcher = OUTPUT_PATTERN.matcher(response);
if (matcher.find()) {
m.setLlmReviewRet(MemoryReviewResult.valueOf(matcher.group(1)));
m.setLlmReviewRet(MemoryReviewResult.getMemoryReviewResult(matcher.group(1)));
m.setLlmReviewCmt(matcher.group(2));
// directly enable memory if the LLM determines it positive
if (MemoryReviewResult.POSITIVE.equals(m.getLlmReviewRet())) {
Expand Down

0 comments on commit 0a6a7de

Please sign in to comment.