mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
(fix)(chat)Remove spaces when obtaining a MemoryReviewResult (#1594)
This commit is contained in:
@@ -1,9 +1,21 @@
|
|||||||
package com.tencent.supersonic.chat.api.pojo.enums;
|
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 {
|
public enum MemoryReviewResult {
|
||||||
|
|
||||||
POSITIVE,
|
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 + "]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class MemoryReviewTask {
|
|||||||
|
|
||||||
Matcher matcher = OUTPUT_PATTERN.matcher(response);
|
Matcher matcher = OUTPUT_PATTERN.matcher(response);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
m.setLlmReviewRet(MemoryReviewResult.valueOf(matcher.group(1)));
|
m.setLlmReviewRet(MemoryReviewResult.getMemoryReviewResult(matcher.group(1)));
|
||||||
m.setLlmReviewCmt(matcher.group(2));
|
m.setLlmReviewCmt(matcher.group(2));
|
||||||
// directly enable memory if the LLM determines it positive
|
// directly enable memory if the LLM determines it positive
|
||||||
if (MemoryReviewResult.POSITIVE.equals(m.getLlmReviewRet())) {
|
if (MemoryReviewResult.POSITIVE.equals(m.getLlmReviewRet())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user