-
Notifications
You must be signed in to change notification settings - Fork 118
快速意图扫描所有react经验 #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
快速意图扫描所有react经验 #49
Changes from all commits
80e5d34
d440cee
9a91fdc
9fcc8f7
bbd402d
3f7d04f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,11 @@ public class ExperienceQuery { | |||||
| */ | ||||||
| private int limit = 5; | ||||||
|
|
||||||
| /** | ||||||
| * 经验候选召回策略。 | ||||||
| */ | ||||||
| private RetrievalMode retrievalMode = RetrievalMode.DEFAULT; | ||||||
|
|
||||||
| /** | ||||||
| * 排序方式 | ||||||
| */ | ||||||
|
|
@@ -64,6 +69,20 @@ public enum OrderBy { | |||||
| SCORE | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * 候选召回策略。 | ||||||
| */ | ||||||
| public enum RetrievalMode { | ||||||
| /** | ||||||
| * 默认策略,由 Provider 自行决定是否走向量召回或普通查询。 | ||||||
| */ | ||||||
| DEFAULT, | ||||||
| /** | ||||||
| * 全量扫描候选集,适用于 FastIntent 等需要穷举匹配的场景。 | ||||||
| */ | ||||||
| FULL_SCAN | ||||||
| } | ||||||
|
|
||||||
| public ExperienceQuery() { | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -119,6 +138,14 @@ public void setLimit(int limit) { | |||||
| this.limit = limit; | ||||||
| } | ||||||
|
|
||||||
| public RetrievalMode getRetrievalMode() { | ||||||
| return retrievalMode; | ||||||
| } | ||||||
|
|
||||||
| public void setRetrievalMode(RetrievalMode retrievalMode) { | ||||||
| this.retrievalMode = retrievalMode; | ||||||
|
||||||
| this.retrievalMode = retrievalMode; | |
| this.retrievalMode = retrievalMode != null ? retrievalMode : RetrievalMode.DEFAULT; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package com.alibaba.assistant.agent.extension.experience.fastintent; | ||
|
|
||
| import com.alibaba.assistant.agent.extension.experience.model.FastIntentConfig; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| class FastIntentServiceTest { | ||
|
|
||
| private final FastIntentService service = new FastIntentService(List.of()); | ||
|
|
||
| @Test | ||
| void messagePrefixShouldTrimByDefault() { | ||
| FastIntentConfig.Condition condition = new FastIntentConfig.Condition(); | ||
| condition.setType("message_prefix"); | ||
| condition.setValue("帮我诊断这个缺陷"); | ||
|
|
||
| FastIntentConfig.MatchExpression expression = new FastIntentConfig.MatchExpression(); | ||
| expression.setCondition(condition); | ||
|
|
||
| FastIntentContext context = new FastIntentContext( | ||
| "\n帮我诊断这个缺陷,缺陷ID:71410746", | ||
| List.of(), | ||
| Map.of(), | ||
| null, | ||
| null | ||
| ); | ||
|
|
||
| assertTrue(service.matches(expression, context)); | ||
| } | ||
|
|
||
| @Test | ||
| void messagePrefixShouldRespectExplicitNoTrim() { | ||
| FastIntentConfig.Condition condition = new FastIntentConfig.Condition(); | ||
| condition.setType("message_prefix"); | ||
| condition.setValue("帮我诊断这个缺陷"); | ||
| condition.setTrim(false); | ||
|
|
||
| FastIntentConfig.MatchExpression expression = new FastIntentConfig.MatchExpression(); | ||
| expression.setCondition(condition); | ||
|
|
||
| FastIntentContext context = new FastIntentContext( | ||
| "\n帮我诊断这个缺陷,缺陷ID:71410746", | ||
| List.of(), | ||
| Map.of(), | ||
| null, | ||
| null | ||
| ); | ||
|
|
||
| assertFalse(service.matches(expression, context)); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query.setRetrievalMode(FULL_SCAN)currently has no effect because noExperienceProviderimplementation readsExperienceQuery#getRetrievalMode()(repo-wide search only finds this setter/getter). Either wire this flag into the provider/repository query logic (e.g., alter candidate recall behavior) or remove the call to avoid misleading behavior.