fix(agent): decouple media analysis from knowledge scope
This commit is contained in:
+3
-2
@@ -195,8 +195,9 @@ public class AihrKnowledgeQueryService {
|
||||
}
|
||||
AihrKnowledgePrincipal principal = projectPrincipal(principalResolver.current(), request.projectCode());
|
||||
AuthenticatedApp app = appService.requireSessionApp(principal.tenantId(), principal.clientKey());
|
||||
Set<Long> spaceIds = accessService.resolveInternalSpaceIds(
|
||||
principal, app, request.spaceCodes(), "READ");
|
||||
Set<Long> spaceIds = mode == MediaMode.MEDIA_ONLY
|
||||
? Set.of()
|
||||
: accessService.resolveInternalSpaceIds(principal, app, request.spaceCodes(), "READ");
|
||||
ConversationContext context = conversationContext(principal, app, request);
|
||||
String extracted = sopService.extractQuestionMedia(file, request.queryText());
|
||||
String extractedContext = extracted == null ? "" : extracted.trim();
|
||||
|
||||
+1
-1
@@ -218,7 +218,6 @@ class AihrKnowledgeQueryServiceTest {
|
||||
var media = new MockMultipartFile("file", "pet.jpg", "image/jpeg", new byte[]{1});
|
||||
when(resolver.current()).thenReturn(principal);
|
||||
when(appService.requireSessionApp("000000", "app")).thenReturn(app);
|
||||
when(access.resolveInternalSpaceIds(principal, app, List.of(), "READ")).thenReturn(Set.of(9L));
|
||||
when(conversations.prepare(principal, app, request)).thenReturn(context);
|
||||
when(conversations.append(any(), any(), any(), anyString(), anyString(), any())).thenReturn(1L);
|
||||
when(sop.extractQuestionMedia(media, "图中是什么宠物")).thenReturn("图中是一只金毛犬");
|
||||
@@ -231,6 +230,7 @@ class AihrKnowledgeQueryServiceTest {
|
||||
assertFalse(result.noEvidence());
|
||||
assertTrue(result.answer().contains("图中是一只金毛犬"));
|
||||
verify(sop, never()).searchAuthorized(any(), any(), any());
|
||||
verify(access, never()).resolveInternalSpaceIds(any(), any(), any(), anyString());
|
||||
var appendedAnswer = ArgumentCaptor.forClass(String.class);
|
||||
verify(conversations).append(any(), any(), any(), anyString(), appendedAnswer.capture(), any());
|
||||
assertTrue(appendedAnswer.getValue().contains("图中是一只金毛犬"));
|
||||
|
||||
Reference in New Issue
Block a user